-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Strategies to reduce Android APK size
This document describes a few strategies that can be used to reduce the resulting APK size when using the Mapbox Android SDK.
ProGuard, even without obfuscation, will remove unused Java code from your code and its dependencies.
The Mapbox SDK ships with 6 architectures:
./arm64-v8a/libmapbox-gl.so
./armeabi/libmapbox-gl.so
./armeabi-v7a/libmapbox-gl.so
./mips/libmapbox-gl.so
./x86/libmapbox-gl.so
./x86_64/libmapbox-gl.so
Each of these files add up to the resulting APK. If, for example, your app doesn't need x86 support, you could drop x86
and x86_64
and save some space. See "ABI splitting" below for details.
This is a feature that lets you build an APK file for each CPU, only containing the relevant native libraries. This process is described in the Android Studio Project Site.
If you distribute your app via Google Play, you can benefit from this approach through the Multiple APK Support distribution feature.
The Mapbox team is actively looking at other ways to reduce the SDK size. Some examples are:
- https://github.com/mapbox/mapbox-gl-native/issues/5656
- https://github.com/mapbox/mapbox-gl-native/issues/2354
- https://github.com/mapbox/mapbox-gl-native/issues/2355
If you have questions or any other ideas, please get in touch with us.
Workflow: Code, Makefile, CMake, Xcode, ccache, Debugging, CI, JS/Native, Code Generation, Versions & Tagging, Contributing, Troubleshooting
Architecture: Threads, Immutability, Expressions, Text Rendering, Collision Detection, CJK Text
Rendering: OpenGL, Coordinate Systems
Android: checkstyle, APK Size, 4→5, 5→6, 6→7, Symbolication
iOS/macOS: 3→4
Releasing: iOS, macOS, Merging back
Misc: Terminology