mindrunner / docker-android-sdk

GNU General Public License v3.0
276 stars 168 forks source link

SDKManager Error: NoClassDefFoundError #100

Closed ArcherEmiya05 closed 5 months ago

ArcherEmiya05 commented 5 months ago
 $ANDROID_HOME/tools/bin/sdkmanager --list

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema

    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)

    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)

    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)

    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)

    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema

    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)

    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)

    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)

Using runmymind/docker-android-sdk:latest

mindrunner commented 5 months ago

Thanks for reporting. Should be fixed in https://github.com/mindrunner/docker-android-sdk/commit/7a459cff3010a36b36ae3cdbf5b78f4c251bf396

ArcherEmiya05 commented 5 months ago

It still happening. Below is my whole script.

  - $ANDROID_HOME/tools/bin/sdkmanager --list # Print the Android SDK's list of installed and available packages, install packages, and update packages https://developer.android.com/tools/sdkmanager#usage
  - echo no | $ANDROID_HOME/tools/bin/avdmanager create avd -n EMU --abi google_apis_playstore/x86_64 -k "system-images;android-34;google_apis_playstore;x86_64" # Create an Android Virtual Device named EMU, the specified ABI and system image will be use for this emulator
  - $ANDROID_HOME/tools/emulator -avd EMU -no-window -no-audio -no-boot-anim & adb wait-for-device # Start emulator without any visual or audio output and block until device is online https://android.googlesource.com/platform/system/core/+/4f6e8d7a00cbeda1e70cc15be9c4af1018bdad53/adb/commandline.c#143
  - ./gradlew connectedAndroidTest --continue # Start instrumented test
  - $ANDROID_HOME/platform-tools/adb devices | grep emulator | cut -f1 | while read line; do $ANDROID_HOME/platform-tools/adb -s $line emu kill; done # Kill all running emulator

In the new Android SDK these are the new paths btw.

$ANDROID_HOME/cmdline-tools/latest/latest/sdkmanager
$ANDROID_HOME/cmdline-tools/latest/latest/avdmanager
$ANDROID_HOME/emulator/emulator
mindrunner commented 5 months ago

Sorry about that. Please try with latest build:

  sdkmanager --list 
  sdkmanager --install "system-images;android-34;google_apis_playstore;x86_64" 
  avdmanager create avd -n EMU --abi google_apis_playstore/x86_64 -k "system-images;android-34;google_apis_playstore;x86_64" 
  emulator -avd EMU -no-window -no-audio -no-boot-anim & adb wait-for-device 

works for me now

ArcherEmiya05 commented 5 months ago

Sorry about that. Please try with latest build:

  sdkmanager --list 
  sdkmanager --install "system-images;android-34;google_apis_playstore;x86_64" 
  avdmanager create avd -n EMU --abi google_apis_playstore/x86_64 -k "system-images;android-34;google_apis_playstore;x86_64" 
  emulator -avd EMU -no-window -no-audio -no-boot-anim & adb wait-for-device 

works for me now

Thanks a lot! Will try it now

ArcherEmiya05 commented 5 months ago

Still not working, I am using it in Bitbucket Pipelines but I don't think it will be an issue right?

          - step: # Step to run instrumented test with aggregated results on all module. Bitbucket test reporting is automatically enabled https://support.atlassian.com/bitbucket-cloud/docs/test-reporting-in-pipelines/
              size: 2x # 2x steps use twice the number of build minutes of a 1x step
              name: Instrumented Test (Aggregated)
              image: runmymind/docker-android-sdk:latest # Docker for Android SDK with pre-installed build tools and emulator image https://github.com/mindrunner/docker-android-sdk
              caches: # Caching speed up subsequent execution https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/
                - gradle

Or I no longer need to specify the path/directory with this image to use the command-line tools?

ArcherEmiya05 commented 5 months ago

It seems that I no longer need to specify the ANDROID HOME and path for sdkmanager however another issue occurred with avdmanager

Error: Package path is not valid. Valid system image paths are:

null

the sdkmanager --list command does not show system-images;android-34;google_apis_playstore;x86_64 it seems that the image is using package-list-minimal.txt? Will try docker-android-sdk:ubuntu-lazydl instead.

ArcherEmiya05 commented 5 months ago

I tried runmymind/docker-android-sdk:ubuntu-lazydl and it fails

bash: sdkmanager: command not found

ArcherEmiya05 commented 5 months ago

For now I just manually install the image that I was gonna use when using the standalone runmymind/docker-android-sdk:latest to fix the issues

sdkmanager "system-images;android-34;google_apis_playstore;x86_64"

mindrunner commented 5 months ago

Of course the image need to be installed:

See https://github.com/mindrunner/docker-android-sdk/issues/100#issuecomment-2081601638

ArcherEmiya05 commented 5 months ago

I tried runmymind/docker-android-sdk:ubuntu-lazydl and it fails

bash: sdkmanager: command not found

Anyway, worth noting