cordova 线程“main”中出现异常java.lang.NoClassDefFoundError:javax/xml/绑定/注解/XML架构

kxxlusnw  于 2022-11-15  发布在  Java
关注(0)|答案(2)|浏览(163)

我正在尝试做一个 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

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

如何解决此问题?
环境:
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

dgjrabp2

dgjrabp21#

我降级到Java 8,它起作用了。
不知道为什么15在这种情况下不起作用。

ws51t4hk

ws51t4hk2#

此答案已过时。Cordova的当前版本使用JDK 11。请在此处尝试答案:cordova cannot see Android target

相关问题