Native libraries not found in ApplicationInfo.nativeLibraryDir when building app bundle for arm64 Android phone

By default, APKs generated from the Android App Bundle have the native libraries uncompressed on devices with Android M / API level 23 or higher (source). Not only does that often reduce the download size but that also considerably reduce the size of the app on devices since the Android platform can directly read the native libraries from the APK instead of having to extract them to a separate location. There was a talk at last I/O on how to reduce the size of your app and how that impacts install numbers, and they detailed how this works if you’re interested in understanding this better.

So, now that you know why Google Play is doing this, you have the following options:

  • You can choose to revert to the original APK behaviour, and this can be done by adding the flag android.bundle.enableUncompressedNativeLibs=false in your gradle.properties file. This will effectively disable this optimization, leading to a bigger size of your app for all your users on M+.

  • You can ensure that the native library is loaded by the Android platform (e.g. using System.loadLibrary) or you if you’re reading the library directly yourself for some reason, read it from the APK directly as well.

If the native libraries are loaded by a third party library you’re depending on, consider filing a bug for them to address this issue so they follow the same logic as the platform.

Hope that helps,

Leave a Comment