Question

In our Android app we have two .so files: one for x86 and another for ARM. They are quite big and are increasing the size of the .apk from 7 MB to 11 MB.

Since .so files are run time entities they have to be inside the .apk files.

Is there any way I could reduce the size of .so files or use/build it in my .apk in a better way?

I got one point from here http://developer.sonymobile.com/2012/01/31/tips-for-reducing-apk-file-size/ i.e. to remove the debug symbols from native code.

Was it helpful?

Solution

The Play Store allows you to upload separate APKs per CPU architecture. So you would have an ARM APK and an x86 APK, rather than one APK with both.

Setting up such APKs is relatively simple with Gradle for Android -- use a separate product flavor for each architecture. I presume that there are recipes for doing this outside of Gradle for Android, though I suspect that it is more involved.

Another approach is to simply not distribute the x86 .so. Modern x86-powered Android devices tend to have libhoudini, which allows them to use ARM .so NDK libraries. However, like with the Android emulator, emulating ARM on x86 is slow, so you'd need to test and see if your app performs acceptably on x86.

And, as Mr. Stratton suggests, particularly if the libraries are yours, see if you can trim the library's size itself. ProGuard doesn't strip out native code the way it strips out Java code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top