Multiple native library architectures (Android)

If multiple native library architectures are included in the APK(s) users download, Emerge will suggest you remove native libraries from architectures that are unsupported on our baseline device (arm64-v8a - Google Pixel 3, Android 12).

Users only need the native libraries specific to their device's application binary interface (ABI). Including ABIs that aren't supported by a device introduces a significant amount of unnecessary bloat, and can easily and safely be removed.

How to resolve

There are a few scenarios in which end-users would receive multiple native library architectures on their device:

  • If receiving a Universal APK from the Play Store
  • If ABI splits are disabled for generated AABs
  • If manual splits are configured and the ABI split is disabled

Universal APKs

It's not actually possible to remove additional ABIs from Universal APKs, as by the name, Universal APKs are intended to support any device.

If shipping to the Play Store, Emerge recommends shipping AABs rather than single, Universal APKs. AABs offer significant app size advantages over Universal APKs, and Google Play requires new apps to publish AABs.

For more reading about the app size advantages of AABs, read Emerge's additional documentation on Split APKs.

ABI split AAB opt-out

AABs can be configured in the Android Gradle Plugin's android {} block with the bundle {} block. By default, all splits are enabled, but any split (density, ABI, language) can be disabled manually.

To ensure users are receiving only the APKs split from the AAB that include only the native libraries necessary for their device, ensure the splitEnabled field inside the abi {} block is set to true, or not present, as the default value is true.

android {
  bundle {
    ..
    
    abi {
      splitEnabled.set(true) // Or can be removed, as default is true
    }
  }
}
android {
  bundle {
    ..
    
    abi {
      splitEnabled = true // Or can be removed, as default is true
    }
  }
}

More documentation on the bundle {} configuration block can be found here.

Manual splits

Similar to the ABI split AAB opt-out with the bundle {} block, the split {} block can be used to output split APKs manually. If configured to skip ABI splits, Android will package all native library architectures into the main split.

Ensure your split Gradle dls config has the isEnabled = true field set for the abi {} block.

android {
  splits {
    ..
    
    abi {
      isEnabled.set(true)
    }
  }
}
android {
  splits {
    ..
    
    abi {
      isEnabled = true
    }
  }
}

More information about the ABI configuration for manual APK splits can be found here.