I am preparing to release an App to production. So, I generated signed apk. After generating signed apk, I was getting a problem. My apk file size is a little large and I tried ways to shrink the apk size. I already tried
app --> Refactor --> Remove Unused Resources
and it is not too reduce. So, I added shrinkResources true in my build.gradle(app)
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
After adding shrinkResources true and I got below error when I rebuild. My question is how should I turn on unused Code shrinking first? Thanks and appreciating.
Resource shrinking works only in conjunction with code shrinking. After the code shrinker removes all unused code, the resource shrinker can identify which resources the app still uses. This is especially true when you add code libraries that include resources—you must remove unused library code so the library resources become unreferenced and, thus, removable by the resource shrinker
To enable resource shrinking, set the shrinkResources property to true in your build.gradle file (alongside minifyEnabled for code shrinking). For example:
android {
...
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}