google / bundletool

Bundletool is a command-line tool to manipulate Android App Bundles
https://g.co/androidappbundle
Apache License 2.0
3.52k stars 385 forks source link

Cannot get device density & install apks to arm64_v8a emulator running on Apple Sillicon M1 #240

Closed fadeltd closed 3 years ago

fadeltd commented 3 years ago

Describe the bug As the title described, I've just got Apple Sillicon M1 machine for development, and as usual, I install latest android studio: arctic fox, and also install the emulator. As Intel x86 emulator don't work on my machine, I tried arm64 emulator, it works when I install apk to the emulator and click run from android studio, but I can't install aab & apks with bundletool as usual, because bundletool can't seem to get the emulator device density.

I use system-images;android-31;google_apis;arm64-v8a system image.

even get-device-spec command won't work, so I can't install apks with --local-testing

Bundletool version(s) affected Version: 1.8.0

Stacktrace

[BT:1.8.0] Error: Error retrieving device density. Please try again.
java.lang.IllegalStateException: Error retrieving device density. Please try again.
    at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
    at com.android.tools.build.bundletool.device.DeviceAnalyzer.getDeviceSpec(DeviceAnalyzer.java:60)
    at com.android.tools.build.bundletool.commands.GetDeviceSpecCommand.execute(GetDeviceSpecCommand.java:162)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:86)
    at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)

To Reproduce Well clearly, --install-apks doesn't work, but to reproduce it easier, get-device-spec also doesn't work, so I don't need to provide my aab, it seems like adb/emulator issue.

java -jar bundletool-all-1.8.0.jar get-device-spec --output=outputs/device-spec.json 

Expected behavior I can install normally like on my intel mac with x86 emulator

Known workaround I haven't been able to install my aab unless I build and use universal apk

Environment: OS: macOS Big Sur 11.2.3 (M1 2020)

sleekweasel commented 3 years ago

Looks related to https://github.com/google/bundletool/issues/241

Android 12 lacks the qemu device density property.

fadeltd commented 3 years ago

Looks related to #241

Android 12 lacks the qemu device density property.

I've confirmed this, it works on Android Q 29 & R 30 arm64-v84 (Both google apis)

system-images;android-30;google_apis;arm64-v8a
system-images;android-29;google_apis;arm64-v8a

This is related to the Android API 31 instead of the emulator with specific abi I'm closing this in favor of #241