Hi Khalid, your APK is still large because R8 can't shrink anything you're telling it to keep. Lines like -keep class com.azure.** { *; }
prevent R8 from removing unused code. Since the Azure SDK itself is quite big, these wildcards stop any real optimization.
Here's what you should do:
First, remove those generic -keep rules. They're blocking most of R8's size savings. Don't worry if the build fails at first; that's expected. When it does, you'll see exactly which classes are actually required, usually a few model classes or things used via reflection.
Next, for each of those, add targeted keep rules. For example: -keep class com.azure.storage.blob.models.BlobItem { *; }
This is much better than keeping entire packages.
Then, inspect your APK using the APK Analyzer in Android Studio. Look for large libraries or native files (like TLS providers or logging libs) that you might have added without needing them. Anything over 2 MB is worth checking.
If you're building a universal APK, consider splitting ABIs or moving to an AAB to avoid bundling all architectures. This alone can cut down 20–40 MB depending on the native libraries you're using.
Finally, use R8’s -whyareyoukeeping
to understand why certain classes are not being removed. This will help you catch dependencies that are holding up your shrinkage.
In terms of size reduction, you can expect roughly:
-50 MB saved by removing those Azure wildcard rules
-20 MB by excluding optional jars you don’t really use
-20–40 MB by splitting ABIs or using an AAB
-Another 10 MB once R8 can fully optimize your code
Most apps that use Azure Blob and OkHttp end up in the 30–50 MB range after doing this cleanup.
A minimal ProGuard rules file should only keep the Azure clients you use, resource IDs, and maybe silence a few irrelevant desktop-related warnings. Everything else should be allowed to shrink.
If after doing this your APK is still larger than expected, share a screenshot of the APK Analyzer's top size offenders or show any strange R8 whyareyoukeeping
results. That way we can narrow it down further.
Give it a try and let me know how much the size drops.