Random Android Gradle Tip: Different Icon per BuildType

Say you want to tell if the version of your installed app is a debug or release version just by looking at the icon on your device. Quick way to do this is to leverage Gradle’s Build type concept.
Build types allow you to create different versions of the same app from the same project. All projects have by default, a debug and release build type. If you want to have a different debug icon from your release icon.

All you have to do is create your launcher icon (debug version) and instead of placing the drawables in the main source set you would install them in the debug source-set. When your project is built in debug mode it would use the matching assets in the debug folder instead of the assets in main source folder. When you build the release version it will use the assets in the release folder if it exists or use the default ones in the main source set. This also holds for build variants.

[1] http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants

 

Android Tint Drawables

Instead of adding multiple image assets that differ only in color to your androd project. Use only 1 asset and use TintDrawables to change the color.  e.g.:


public static void setImageColor(ImageView image,int color){
DrawableCompat.setTint(image.getDrawable(), color);
}

see the below gist for an example:
[1] https://gist.github.com/ckurtm/8e185ad9b4df9c0f98d1
[2] https://developer.android.com/reference/android/support/v4/graphics/drawable/DrawableCompat.html#setTint(android.graphics.drawable.Drawable, int)