Configure your Reader SDK project to generate multiple APK files for different application binary interfaces (ABIs).
Reader SDK

Configure APK Splits Across ABIs

Configure your Reader SDK project to generate multiple APK files for different application binary interfaces (ABIs). Before you start, you must install and configure the Reader SDK.

You can configure APK splitting for each of the different supported ABI architectures. If you do this, you have to ship multiple APK files, but they are 35 MB – 40 MB smaller than a universal APK file.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
android {
  // ...
  splits {
    abi {
      enable true
      reset() // clear from 'all ABIs' to 'none'
      include 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
      universalApk true //make a universal APK along with ABI specific apks
    }
  }
}

// Map for the version code that gives each ABI a value.
ext.abiCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'x86':4, 'x86_64':5]

import com.android.build.OutputFile

// For each APK output variant, override versionCode with a combination of
// ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
android.applicationVariants.all { variant ->

  // Assigns a different version code for each output APK
  // other than the universal APK.
  variant.outputs.each { output ->

    // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
    def baseAbiVersionCode =
        // Determines the ABI for this variant and returns the mapped value.
        project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))

    // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
    // the following code does not override the version code for universal APKs.
    // However, because we want universal APKs to have the lowest version code,
    // this outcome is desirable.
    if (baseAbiVersionCode != null) {

      // Assigns the new version code to versionCodeOverride, which changes the version code
      // for only the output APK, not for the variant itself. Skipping this step simply
      // causes Gradle to use the value of variant.versionCode for the APK.
      output.versionCodeOverride =
          baseAbiVersionCode * 1000 + variant.versionCode
    }
  }
}

If you need more assistance, contact Developer Support or ask for help in the Developer Forums.