To enable resource shrinking, set the shrinkResources
property to true in your build.gradle
file.
android {
...
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Pay attention because resource shrinking works only in conjunction with code shrinking.
You can customize which resources to keep or discard creating an XML file like this:
<?xml version=1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@layout/mylayout,@layout/custom_*"
tools:discard="@layout/unused" />
Save this file in res/raw
folder.