Skip to content

Reduce the APK size

Stefano Brusadelli edited this page Sep 25, 2020 · 7 revisions

Bandyer Android SDK has been built upon native libraries. The SDK must be shipped with those libs in various flavors for every cpu architecture.

We currently support usage for the following cpu architectures:

  • arm64_v8a
  • aremabi-v7a
  • x86
  • x86_64

Including Bandyer Android SDK will include in your app all the native libraries for all the cpu architectures.


How to reduce size

There are two ways to optimize the size of the APK which will be delivered to the users:

  1. Publish your app using the AAB format
  2. Split your APK builds based on cpu architectures and optionally based on screen densities if your app has lots of resources for different screen sizes

1. AAB format

By delivering your application with the AAB format, Google Play will take care of generating and serving APK for each device configuration, and only the code and resources needed for a specific device are downloaded to run the app. This will save your time because you don’t have to build, sign and manage multiple APKs to optimize the support for different devices anymore. You can visit the following link: https://developer.android.com/guide/app-bundle to have a deepful insight about the App Bundle format and know what it offers.

2. Split APK build

If you don’t want to use the AAB format for some reason, you can still split APK builds based on cpu architectures and screen densities. We included in the demo app's build.gradle a sample code for this purpose:

android {

    [...]
    
    splits { 

        abi {
            enable true
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
            universalApk false
        }

        // Optionally configures multiple split APKs based also on screen density.
        density {
            enable true
            compatibleScreens 'small', 'normal', 'large', 'xlarge'
        }
    }

}

Building split APKs will typically reduce the SDK footprint size by ~20Mb.

Keep in mind that in order to upload multiple APKS to play store:

  • All APKs published for the same application must have the same package name and be signed with the same certificate key.
  • Each APK must have a different version code, specified by the android:versionCode attribute.

It is possible to override this value in build.gradle file for each split APK. For further information please refer to: https://androidbycode.wordpress.com/2015/06/30/android-ndk-version-code-scheme-for-publishing-apks-per-architecture/


For further information please refer to: https://developer.android.com/studio/build/configure-apk-splits.html

Clone this wiki locally