Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing apk size which has .so files

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.

like image 620
saurav Avatar asked Jul 29 '14 16:07

saurav


People also ask

Can you compress APK files?

With provisions such as Proguard, one can compress the APK file size and optimize libraries easily.

Which image codec should be used for optimize APK size?

You can also reduce your APK size by procedurally rendering your images. Procedural rendering frees up space because you no longer store an image file in your APK. You can reduce PNG file sizes without losing image quality using tools like pngcrush, pngquant, or zopflipng. Use WebP file format and Use vector graphics.

How do I reduce file size on Android?

Using an online PDF compressor. You can use the Adobe Acrobat online PDF compressor to compress a PDF file on an Android device without additional apps. Open your browser and navigate to the Acrobat online PDF compressor. Tap on Select a File and locate your PDF on your Android device. Download your compressed PDF.


1 Answers

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.

like image 81
CommonsWare Avatar answered Oct 30 '22 04:10

CommonsWare