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

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

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

问题

我正在尝试制作一个 Cordova 插件。我所做的是:

$ cordova create toasty-plugin-test com.stanleyidesis.toastyplugintest ToastyPluginTest
$ cd toasty-plugin-test
$ cordova platforms add android
$ cordova requirements

然后出现了下面的错误:

[boy@Plum toasty-plugin-test ]$ cordova requirements

android 的要求检查结果:
Java JDK:已安装 15.0.1
Android SDK:已安装 true
Android 目标:未安装
命令以退出代码 1 失败:avdmanager list target
主线程中的异常 "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.AvdManagerCli.run(AvdManagerCli.java:213)
	at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 5 more
Gradle:已安装 /usr/local/Cellar/gradle/6.7/bin/gradle
部分要求检查失败

我该如何解决这个问题?

环境:

macOS - Catalina,10.15.6

[boy@Plum toasty-plugin-test ]$ which java
/usr/bin/java
[boy@Plum toasty-plugin-test ]$ which javac
/usr/bin/javac
[boy@Plum toasty-plugin-test ]$ java -version
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

此外,我已安装了 AndroidStudio 4.1。

英文:

I am trying to make a cordova plugin.
What I did

$ cordova create toasty-plugin-test com.stanleyidesis.toastyplugintest ToastyPluginTest
$ cd toasty-plugin-test
$ cordova platforms add android
$ cordova requirements

And the error below happens

[boy@Plum toasty-plugin-test ]$ cordova requirements

Requirements check results for android:
Java JDK: installed 15.0.1
Android SDK: installed true
Android target: not installed 
Command failed with exit code 1: avdmanager list target
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.AvdManagerCli.run(AvdManagerCli.java:213)
	at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 5 more
Gradle: installed /usr/local/Cellar/gradle/6.7/bin/gradle
Some of requirements check failed

How can I fix this issue?

environment:

macOS - Catalina, 10.15.6

[boy@Plum toasty-plugin-test ]$ which java
/usr/bin/java
[boy@Plum toasty-plugin-test ]$ which javac
/usr/bin/javac
[boy@Plum toasty-plugin-test ]$ java -version
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

Also, I've installed AndroidStudio 4.1

答案1

得分: 1

我降级到了Java 8,它起作用了。

不知道为什么在这种情况下15不起作用。

英文:

I downgraded to Java 8 and it worked.

Don't know why 15 doesn't work in this case.

答案2

得分: 0

这个回答已经过时。Cordova 的当前版本使用 JDK 11。请尝试这里的回答:
https://stackoverflow.com/questions/46426854/cordova-cannot-see-android-target

英文:

This answer is outdated. The current version of Cordova uses JDK 11. Try the answers here:
https://stackoverflow.com/questions/46426854/cordova-cannot-see-android-target.

huangapple
  • 本文由 发表于 2020年10月22日 21:12:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/64483045.html
匿名

发表评论

匿名网友

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

确定