Add option to configure Android ABIs
Generated APKs and AABs currently include the following ABIs:
- armeabi-v7a
- arm64-v8a
- x86_64
We can't drop armeabi-v7a yet, because there are still too many 32-bit devices in use (see https://github.com/chaquo/chaquopy/issues/709). However, we were OK to drop 32-bit x86 because we set our minimum API level to 26 (https://github.com/beeware/briefcase-android-gradle-template/pull/49), and 64-bit emulator images have been available since level 21. Since BeeWare developers will need to use a 64-bit emulator image anyway to test on the current version of Android, requiring them to do the same on the other versions is no great inconvenience. And omitting x86 reduces the APK size and makes it faster to build and install.
Anyway, there are legitimate reasons for developers to want to change the set of available ABIs, so we should make this configurable in pyproject.toml. See https://github.com/beeware/briefcase-android-gradle-template/pull/52#discussion_r935822715 for discussion of possible approaches.
Other open issues that may involve updating the Android template:
- https://github.com/beeware/briefcase/issues/547
- https://github.com/beeware/rubicon-java/discussions/75#discussioncomment-3224352
+1.
Flagging this as "first timers" because the actual change isn't especially complex:
- Modify the Android Gradle template to explicitly specify the supported platforms. See this documentation for the configuration change that is required. This should be controlled by the template, with the NDK configuration block only being included if the template context provides a value.
- Modify the Android Gradle backend to include the list of supported platforms in the template context. This should be extracted from the the app configuration using a new
android_abissetting; it will fall back to "None" if not specified. - Document for the new (optional)
android_abisAndroid configuration setting.
For example, a project configuration of:
[tool.briefcase.app.myapp.android]
android_abis = ['arm64-v8a', 'x86_64']
would result in a build.gradle file that contains:
...
defaultConfig {
applicationId "com.example.helloworld"
...
ndk {
abiFilters 'arm64-v8a', 'x86_64'
}
However, if the user doesn't specify android_abis, the ndk block would not be included.
The above comment is valid for the current Rubicon template. After we switch to Chaquopy, the abiFilters setting will be compulsory, because the Chaquopy plugin requires it. I did this because defaulting to all 4 ABIs could make the APK too large, so I thought it was better to force the user to be explicit about what they wanted.