stetho-timber Library issue with new Timber 4.1.2


While I was trying to use stetho-timber Library in my Android application I faced this problem:

Error:Module 'com.facebook.stetho:stetho-timber:1.3.1' depends on one or more Android Libraries but is a jar

After inspecting in its codes I found that it uses timber v3.0.1!

Just add this to your build.gradle dependencies tag to exclude timber within the stetho library,
cause it is an old version and conflicts with new one:

dependencies {
    compile ("com.facebook.stetho:stetho-timber:1.3.1") {
        exclude group: "com.jakewharton.timber", module: "timber"

I have recently found Facebook Stetho Library and using it is fantastic, give it a try! :)

How to add Vector image support to old Android versions using new AppCompat?


Finally we had vector support for all Android versions, 8-)

  • bye bye all different PNG size files in different drawable folders!
  • bye bye FontAwesome!
  1. first of all add these dependencies to your module’s build.gradle:
dependencies {
    compile ''
    compile ''
  1. add this to your android defaultConfig tag in your module’s build.gradle:
android {

    defaultConfig {
        vectorDrawables.useSupportLibrary = true
  1. replace all your ImageView with
    and ImageButton with in all your project’s xml layouts.

  2. replace all android:src attribute in all ImageView with app:srcCompat.

  3. now import your vector image using New -> “Vector Asset” submenu by right clicking on your drawable folder…

That’s it!!!

Best practise for Logcat colours in Android Studio!

Android Studio Logcat color scheme Preferences

I know that using solid black colour logcat in Android Studio  is awful !!!

Here is my best practice colour codes that you can use for changing the face of you logcat in Android Studio to make it more useful. go to Android Studio Preferences and search for logcat and save as your own scheme:


All colours are picked from material design colour pattern:

App Settings


This is a best practice for Android Applications Config Management using Shared Preferences.
AppSettings class help you to manage deferent types of data in your application and load them in memory for faster use also save them in shared preferences for next run.

  • Eliminate SharedPreferences and Editor Commits calls.
  • Different method ovverride to set and get all data types.
  • Allow to use different XML files for saving and accessing settings.

Github_LogoGithub repo:

// load saved values
 private void loadValues() {
 etName.setText(AppSettings.getString(this, KEY_NAME, ""));
 spAge.setSelection(AppSettings.getInt(this, KEY_AGE, 0));
 rbMale.setChecked(AppSettings.getBoolean(this, KEY_IS_MALE, true));
 rbFemale.setChecked(!AppSettings.getBoolean(this, KEY_IS_MALE, true));
 sbWeight.setProgress((int) (AppSettings.getFloat(this, KEY_WEIGHT, 0f) * WEIGHT_FACTOR));

 // clear saved values
 private void clearValues() {
 AppSettings.clearValue(this, KEY_NAME);
 AppSettings.clearValue(this, KEY_AGE);
 AppSettings.clearValue(this, KEY_IS_MALE);
 AppSettings.clearValue(this, KEY_WEIGHT);


 // save input values
 private void saveValues() {
 AppSettings.setValue(this, KEY_NAME, etName.getText().toString().trim());
 AppSettings.setValue(this, KEY_AGE, spAge.getSelectedItemPosition());
 AppSettings.setValue(this, KEY_IS_MALE, rbMale.isChecked());
 AppSettings.setValue(this, KEY_WEIGHT, (float) sbWeight.getProgress() / WEIGHT_FACTOR);

Grab via Maven:


or Gradle:

compile 'com.mirhoseini.appsettings:appsettings:1.0.1'

How to solve “Duplicate files copied in APK META-INF/LICENSE.txt”?


Sometimes depends on libraries that you have used in your Android project this annoying error shows up during gradle build using Android Studio: Duplicate files copied in APK META-INF/LICENSE.txt

can be solve this issue and many more by adding this to the Android tag of your build.grade file:

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'

How to enable Android retrofit2 network library logging?


As any one who had an experiment with retrofit2 knows, logging is some times required to check what is happening!

Since the retrofit2 required HTTP layer is now completely based on OkHttp, the developers of OkHttp added a logging interceptor in release 2.6.0

add to your build.gradle file:

dependencies {
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.0-RC1'

and this is how to build retrofit:

Retrofit.Builder builder = new Retrofit.Builder()

        //show retrofit logs if is debugging
        if (sIsDebug) {
            HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
            OkHttpClient.Builder httpClient = new OkHttpClient.Builder();


        mRetrofit =;

now have fun with logs at logcat…

How to enable the three-finger drag gesture in OS X El Capitan


Step 1: Open System Preferences

Step 2: Click Accessibility

Step 3: Click Mouse & Trackpad

Step 4: Click Trackpad Options…

Step 5: Click Enable dragging

Step 6: Select “three finger drag” in the drop down box

Not only does the three finger drag gesture allow you to move around windows and other desktop items, it also allows you to select text.

Tehran Traffic Map App v4.0.2 Released!


Tehran Traffic Map IconTehran Traffic Map
Category: Transportation
Version: 4.0.2
Size: 3.3 MB

Tehran Traffic Map
This Android application use your mobile internet connection (WIFI/GPRS) to show a real-time Traffic information for surface street traffic conditions within the city of Tehran. All information received from “Tehran Traffic Control Co.” cameras server and visualize on a map. It is a dual language program (Persian/English depending on device default language).
It also lets you zoom on the streets and compare new received and older map.