dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

JAVA0000 + java.lang.IllegalStateException when installing an app #7348

Open jonpryor opened 2 years ago

jonpryor commented 2 years ago

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.), Android for .NET (net6.0-android, etc.)

Affected platform version

main

Description

"Random"/occasional error when running the Install target, e.g. on CI for the MonoAndroidExportReferencedAppStarts(True,"",True) unit test:

Task "InstallApkSet"
  …
  /Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.16-101/x64/Contents/Home/bin/java -Xmx1G -jar /Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.0-ci.pr.gh7342.159/tools/bundletool.jar install-apks --apks obj/Release/android/bin/x_com.xamarin.monoandroidexportreferencedappstarts.apks --adb /Users/runner/Library/Android/sdk/platform-tools/adb --allow-downgrade --modules _ALL_
  error: Error retrieving device SDK version. Please try again.
  java error JAVA0000: java.lang.IllegalStateException
  java error JAVA0000:  Error retrieving device SDK version. Please try again.
  java error JAVA0000:  at com.google.common.base.Preconditions.checkState(Preconditions.java:508)
  java error JAVA0000:  at com.android.tools.build.bundletool.device.DeviceAnalyzer.getDeviceSpec(DeviceAnalyzer.java:57)
  java error JAVA0000:  at com.android.tools.build.bundletool.commands.InstallApksCommand.execute(InstallApksCommand.java:185)
  java error JAVA0000:  at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:91)
  java error JAVA0000:  at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:49)

Only this one test failed, so it seems unlikely that the Android emulator is "bad".

Should we check for Please try again and re-run the bundletool.jar invocation on failure?

Steps to Reproduce

Happens randomly. No reproduction steps.

Did you find any workaround?

No response

Relevant log output

No response

dellis1972 commented 2 years ago

This might be tricky as the InstallApkSet task at the end of the day uses ToolTask to execute the command. We might be able to hack around this , perhaps when we are just on CI maybe? via a AndroidRetryInstall property or something ...