Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APK size increased 35mb when bumping min SDK from 21 to 24

Recently we bumped our min supported SDK from API 21 to 24.

Apparently this change caused our APK size to increase from 65mb to 103mb. From the APK analysis in Android studio, we can see it's all of the .so files that have basically doubled in size.

But why would that be? No gradle properties have changed, just the min sdk.

Any thoughts on how to decrease the APK size again?

like image 975
im_not_josh Avatar asked Jun 17 '20 23:06

im_not_josh


People also ask

Why is my APK size so big?

One of the simple ways to make your APK smaller is to reduce the number and size of the resources it contains. In particular, you can remove resources that your app no longer uses, and you can use scalable Drawable objects in place of image files.

What is the maximum size of an APK?

Each expansion file can be up to 2GB in size. Users must run Play Store version 5.2 or higher to install 100MB APKs.

Why is react native app size so big?

Generally, React Native app size is big, which has always been an issue. As React Native applications support various CPU architectures and devices. Due to this, every device that downloads the application will get the unnecessary code that makes to React Native app size too big.


1 Answers

Any thoughts on how to decrease the APK size again?

According to this answer on reddit and this issue on Google issue tracker that's because starting with API 23 the platform can read native libraries without extracting them if they are uncompressed.

If you declare minSdk 23 or higher, building the APK with uncompressed native libraries should save space on devices because:

  • APK is compressed before download anyway, so download size doesn't change
  • after installation, there's only one copy of the library (uncompressed inside APK)

When I just tested this, the size after installation was actually higher with minSdk 23 compared to 22, contrary to what they say should happen. That is because the APK includes libraries for all ABIs. If I use only one ABI it is a bit smaller with minSdk 23.

So until you start splitting the APK or use App Bundle (which is pretty easy and can decrease the size even more), you may want to set android:extractNativeLibs="true" in your AndroidManifest.xml to get the old behavior.

like image 99
arekolek Avatar answered Oct 26 '22 08:10

arekolek