Why does the APK package size increase after setting Android minSdkVersion to 23?
This is because when minSdkVersion is 23 or higher, AGP (Android Gradle Plugin) will no longer compress the so files in the APK by default, so the packaged APK will be larger. For specific reasons, refer to the "Detailed Description" section below.
However, developers need not worry about the download size of the package increasing after uploading to the app store, because app stores generally use compression patches to compress the uploaded APK again.
Detailed Description
Android 23 and above can read so files directly from the APK without extracting them. Therefore, if the API level (corresponding to minSdkVersion) is 23 or higher, AGP will no longer compress the so files in the APK by default.
If minSdkVersion is 23 or higher and the developer has not manually set android
="true", the system will automatically inject android="false" in the manifest.The android
setting determines whether the package installer extracts native libraries from the APK to the file system. If set to "false", native libraries must remain page-aligned and stored uncompressed in the APK. No code changes are needed because the linker will load the libraries directly from the APK at runtime.For details about android
, refer to the official documentation.This means that although the APK size will increase, the actual installed application size is actually smaller:
- When API < 23, the installed application includes compressed so files and decompressed so copies extracted from the APK.
- When API >= 23 and android="false", the installed application only includes uncompressed so files without extracted so copies.
