bundletool
bundletool copied to clipboard
Bundletool does not recognize `android:installLocation="0"`
Background
We are exploring uncompressed native libraries for our application and observed an issue where Bundletool is not respecting the installLocation
flag for disabling uncompressed native libraries for Android 6 to 9 where the app may be installed on external storage (and consequently lead to a security exception).
Within our AndroidManifest.xml, we've got the following, android:installLocation="0"
, which is equivalent to android:installLocation="auto"
. In our source code we are using android:installLocation="auto"
so some intermediate step in our build system, which leverages Bazel's rules_android
, is performing this translation before we generate the App Bundle.
Issue
Bundletool assumes that android:installLocation
is a string value and fails to process android:installLocation="0"
.
name: "installLocation"
source {
}
resource_id: 16843447
compiled_item {
prim {
int_decimal_value: 0
}
}
// Returns 0
appBundle.getBaseModule().getAndroidManifest().getManifestElement().getAndroidAttribute(AndroidManifest.INSTALL_LOCATION_RESOURCE_ID).get().getValueAsInteger()
// Returns ""
appBundle.getBaseModule().getAndroidManifest().getManifestElement().getAndroidAttribute(AndroidManifest.INSTALL_LOCATION_RESOURCE_ID).get().getValueAsString()
This occurs here: https://github.com/google/bundletool/blob/master/src/main/java/com/android/tools/build/bundletool/model/AndroidManifest.java#L739
/** Returns the string value of the 'installLocation' attribute if set. */
public Optional<String> getInstallLocationValue() {
return getManifestElement()
.getAndroidAttribute(INSTALL_LOCATION_RESOURCE_ID)
.map(XmlProtoAttribute::getValueAsString);
}
It's possible that there are other places within AndroidManifest.xml
that cannot properly account for integers instead of strings.
If it would help, I can share our App Bundle or email to test other potential breakages in Android Manifest introspection.