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

huangapple go评论143阅读模式
英文:

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

问题

我在MacOS上安装了AdoptOpenJDK的JDK 8(LTS)来设置Android环境,一切正常运行。

但是在运行sdkmanageravdmanager时出现以下错误,原因是Gradle 6.5.1现在需要JVM 14.0.1(Oracle Corporation 14.0.1+14)。

根据这里的建议https://stackoverflow.com/a/51644855/6716408,解决方法是降级Java版本,但这是不可能的,因为Gradle依赖于Java。

有任何解决方案吗?

英文:

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?

答案1

得分: 2

以下是翻译好的部分:

Google的cmdline-tools包含一个替代版本的avdmanager,可以在Java 9及更高版本下正常运行。 cmdline-tools应该安装在~/Android/Sdk/cmdline-tools/latest目录下。请使用该路径下的avdmanager。

更新.zshrc/.bash_profile,如下所示:

# 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  // 移除此行
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin // 添加此行
export PATH=$PATH:$ANDROID_HOME/platform-tools
英文:

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

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

# 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

<!-- end snippet -->

答案2

得分: 1

你不需要降级 Java。你仍然可以使用 OpenJDK 11。如果你已经安装了 Android Studio,只需确保安装了最新的 Android SDK 命令行工具。

文件 > 设置 > 外观和行为 > 系统设置 > Android SDK > SDK 工具

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

英文:

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

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

huangapple
  • 本文由 发表于 2020年8月5日 00:36:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63251321.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定