I compiled an application for Android, using Android NDK. And I have two projects. First - is a library with ndk libs and jni folder. Second - is my working application which includes first project as a library. The size of my app is too big as for me (30Mb). And i want decrease it. I read tutorials, but they tell to do basic options, such as deleting logs and unused code, etc. But this doesn't help me. Can I delete jni folder with all my .c files (if i am correct in final build they are unnecessary, because they are compiled into .so libs), or this doesn't decreases the size of apk? Or may be i should do something else? Thank you for interest to my question!
-
1The standard android build only copies the .so files. It does not copy any .c source or header files. You might want to investigate the size of other assets, such as artwork. You can open the apk file with a tool such as `7zip` and investigate which files take up the most space. If that doesn't help, you might want to investigate the usage of OBB files, where you can store additional data. http://developer.android.com/google/play/expansion-files.html – tillaert Feb 08 '14 at 09:23
-
Thank you, tillaert. I'll try these solutions. – bukka.wh Feb 08 '14 at 10:19
4 Answers
You can enable ABI splitting in the build.gradle file like this:
android {
// Some other configuration here...
splits {
abi {
enable true
reset()
include 'x86', 'armeabi', 'armeabi-v7a', 'mips'
universalApk false
}
}
}
This will reduce your application size by a much greater extent.
The reason is that now Gradle will generate one APK per CPU reducing the size even further!
In my case it reduced my apk file size from 5.4mb to 3.2mb.

- 7,179
- 4
- 43
- 57
You may also check for any used 3rd party library, and see if any unnecessary extensions may be disabled.
For once I used assimp with full support of all loaders and it adds over 10MB to my app. By removing unnecessary modules from it, the result is much less bloat.

- 3,841
- 1
- 19
- 26
If your Application.mk
has line
APP_ABIS = all
or similar, consider shipping separate APKs for different platforms (armeabi, armeabi-v7a, x86, mips).
The technical details are discussed at length in Android - build separate APKs for different processor architectures
-
That seems to be very interesting link because each my lib for each platform has big size. I'll check the link! – bukka.wh Feb 08 '14 at 13:49
You should take a look at:
- Reducing your Android APK size When Using Native Libraries: Link Time Optimization
- Redex: Android bytecode (dex) optimizer
- Build Multiple APKs: Split APK by dentity and architecture
- Reduce APK Size: For reducing or removing unnecessary resources (you already started this one in your question, but it's here for reference to someone else)

- 81
- 4