-
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 Maps SDK for Android.
ProGuard and DexGuard, 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.
Leveraging apk splits is one of the tips we give users when it comes to shrinking their apk size. Splitting results in building different apks for the different supported abis in an application. Google Play is optimised to only download the apk for the abi of the device that is installing the app.
Mapbox publishes a Demo App to the Google Play store that showcases core SDK features.
This app is open source and benefits from APK splitting for smaller binary distribution. You can learn how we do this in the build.gradle
file.
The Mapbox team is actively looking at other ways to reduce the SDK size (e.g. dropping support for deprecated architectures).
If you have questions or ideas that you'd like to share, 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