locropulenton
locropulenton

Reputation: 4853

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

I am on MacOS, installed the JDKs 8 ( LTS ) from AdoptOpenJDK to get the android environment up and running and that worked fine!

brew cask install adoptopenjdk/openjdk/adoptopenjdk8

But Getting the following error while running sdkmanager or avdmanager due to the fact the Gradle 6.5.1 now requires JVM 14.0.1 (Oracle Corporation 14.0.1+14).

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

As it is suggested here https://stackoverflow.com/a/51644855/6716408 the fix is downgrading the java version but that is not possible because gradle's java dependency.

Any solutions?

Upvotes: 3

Views: 2251

Answers (2)

Kevin Le - Khnle
Kevin Le - Khnle

Reputation: 10857

You don't have to downgrade Java. You can still use OpenJDK 11. If you have Android Studio installed, just make sure Android SDK command-line tools latest is installed.

File > Settings > Appearance & Behavior > System Settings > AndroidSDK > SDK Tools

enter image description here

Upvotes: 1

Shi Quan
Shi Quan

Reputation: 761

the cmdline-tools package from Google contains a replacement version of avdmanager that runs fine under Java 9 and upwards. The cmdline-tools should be installed in ~/Android/Sdk/cmdline-tools/latest. Use the avdmanager from that path instead.

update .zshrc/.bash_profile,like beblow

# android sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
# export PATH=$PATH:$ANDROID_HOME/tools/bin  // remove this line
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin // add this line
export PATH=$PATH:$ANDROID_HOME/platform-tools

Upvotes: 4

Related Questions