Last Updated: February 25, 2016
· alouanemed

Remove unused resources on Android with Gradle

A Googler published a note about a new feature of the updated version of Gradle plugin for Android.

It can automatically remove unused resources. The big win here is that it removes unused resources not just from your own code, but more importantly from libraries you are using (e.g. where there are resources included to support features that you are not actually using from your app). Please try it on your own application projects to see what the net gain is (and of course, to verify that it works! Please report any bugs you encounter!).

Automatic resource shrinking is off by default; to enable it, add "shrinkResources true" to your build type. Note that this feature relies on code shrinking first, so it requires minifyEnabled to be true as well:

android {
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true