When I was creating the app "Check the Cheque" and uploading it to Google Play, I was wondering if its possible to shrink the app size. The app I was working on was like 2 MB and I knew that it was too big for an app that only had like one picture and only a few 100 lines of code. I searched on the Android User guide and it I came across the "Shrink Your Code and Resources" and I never knew that Android Studio had this feature. Also this is free because it's distributed under the GPL (General Public License). So I will compare how much smaller my app went from 2 MB, to 0.9 MB.
First thing first, I had one PNG image that was like around 500 KB file size and I wanted to convert it to WebP image. So going to the documentation at user guide named "Create WebP Images" show how easy it was to convert the image. However, it only works if you are working on an app that uses Android 4.3 (API level 18) and higher. So the image went from 500 KB to 65KB. Pretty good so far.
OK, 1.4 MB, but that was a reduction of the image. Working with Proguard is simple: just go to your app's Build.Gradle (Module: app) and change the code from:
buildTypes {
release {
debuggable false
minifyEnabled false
shrinkResources false
}
to this:
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Now check out the new size. Wow! From 2 MB to 911KB size android app.
We are not done yet, Proguard creates a file called mapping.txt and this is a valuable information that is used to share detailed crash and analytics data in your Google Play console and its in the left menu( click Android vitals > ANRs & Crashes) And just upload the mapping.txt and you are set.
Special thanks to these web sites and people for teaching me about Proguard: