google / bundletool

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

Error retrieving device SDK version. Please try again. #290

Open vocasle opened 2 years ago

vocasle commented 2 years ago

Describe the bug java -jar bundletool.jar build-apks fails to produce *.apks with error: Error retrieving device SDK version. Please try again

Bundletool version(s) affected Version: 1.9.1

Stacktrace

[BT:1.9.1] Error: Error retrieving device SDK version. Please try again.
java.lang.IllegalStateException: Error retrieving device SDK version. Please try again.
        at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
        at com.android.tools.build.bundletool.device.DeviceAnalyzer.getDeviceSpec(DeviceAnalyzer.java:57)
        at com.android.tools.build.bundletool.commands.BuildApksModule.provideDeviceSpec(BuildApksModule.java:141)
        at com.android.tools.build.bundletool.commands.BuildApksModule_ProvideDeviceSpecFactory.provideDeviceSpec(BuildApksModule_ProvideDeviceSpecFactory.java:36)
        at com.android.tools.build.bundletool.commands.BuildApksModule_ProvideDeviceSpecFactory.get(BuildApksModule_ProvideDeviceSpecFactory.java:27)
        at com.android.tools.build.bundletool.commands.BuildApksModule_ProvideDeviceSpecFactory.get(BuildApksModule_ProvideDeviceSpecFactory.java:10)
        at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
        at com.android.tools.build.bundletool.commands.DaggerBuildApksManagerComponent.create(DaggerBuildApksManagerComponent.java:214)
        at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:793)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:77)
        at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)

To Reproduce

@echo off

set AAB=%1
set APKS=%2
set DEVICE=%3

echo Removing old <ProjectName>.apks
del %APKS%.apks
echo Building <ProjectName>.apks
java -jar bundletool.jar build-apks --bundle=%AAB% --output=%APKS%.apks --device-id=%DEVICE% --connected-device --ks=<keystore>.keystore --ks-key-alias=<alias> --local-testing --ks-pass=pass:<pass>
echo Installing <ProjectName>.apks
java -jar bundletool.jar install-apks --device-id=%DEVICE% --apks=%APKS%.apks

Expected behavior

  1. There should be a .apks in the same directory in which script was executed
  2. .apks should successfully installed on device

Known workaround No workarounds yet.

Environment: OS: Android 10 (Samsung Galaxy A21s)

Additional context *.aab is generated by Unreal Engine 4.27. Right now this is the only device with that error.

adb shell getprop ro.build.version.sdk returns 29.

ymakhno commented 2 years ago

I think it might be fixed in the latest version.

CW3MH6 commented 1 year ago

One person on my team gets this error randomly. Both on the latest version of bundletool and older versions. Across multiple versions and installs of android-sdk. Everyone else on the team seems to work fine. It happens during install-apks step

Java Version 18.0.2.1 Device: Pixel 6 on Android 13