Android App Bundle

If you publish your app to Google Play, you should build and upload an Android App Bundle. When you do so, Google Play automatically generates and serves optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app. Publishing multiple APKs is useful if you are not publishing to Google Play, but you must build, sign, and manage each APK yourself. For more info read - https://developer.android.com/guide/app-bundle/

Proguard

By using Proguard Developers can shrink, obfuscate, and optimize their apps. To enable proguard just add "minifyEnabled true" in your build config.

buildTypes {
	release {
		minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
  debug {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

As of version 2.13.6 the PulsateSDK imports with Proguard settings, turning on Proguard will automatically run the PulsateSDK settings.

APK Splitting

If you can't use Android App Bundles you can manually split your APK into multiple APKs and upload them to Google Play. Google Play makes sure that the user gets the APK that is for his device.
All you need to do is add the following block of code to your app gradle file under android.

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

When releasing an app Android Studio will now build multiple APKs (one for every architecture). This will reduce the size of your app, but you will need to now manage multiple different APKs. For more info read - https://developer.android.com/google/play/publishing/multiple-apks.html

ABI filters

Instead of building multiple APKs you can create a single APK with just the architectures that you need. This APK will be larger than the APKs we get from using APK Splitting, but we have only one APK to manage. ABI filters allow us to filter certain kind of architecture(s) that we want to include into single APK file.

buildTypes {
    release {
        ndk {
            abiFilters "arm64-v8a", "armeabi-v7a"
        }
    }
}

By removing unnecessary architectures we can generate a single APK file that is much smaller (notice that there are not many devices that support x86 architecture for Android, but the libraries for this architecture are the biggest ones).

Other

For more ways to reduce App Size please read:

  1. https://developer.android.com/studio/build/shrink-code
  2. https://developer.android.com/topic/performance/reduce-apk-size
  3. https://developer.android.com/google/play/publishing/multiple-apks.html
  4. https://developer.android.com/guide/app-bundle/