“java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"接受 SDK 许可时 [英] "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema" when accepting SDK licenses

查看:33
本文介绍了“java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"接受 SDK 许可时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我正在尝试使用 Android Studio 构建我的 React-Native 应用程序.我在构建时第一次遇到这个错误:

无法安装以下 Android SDK 包,因为某些许可证未被接受.构建工具;29.0.2 Android SDK 构建工具 29.0.2要构建此项目,请接受 SDK 许可协议并使用 Android Studio SDK 管理器安装缺少的组件.或者,要将许可协议从一个工作站转移到另一个工作站,请参阅 http://d.android.com/r/studio-ui/export-licenses.html使用 Android SDK:C:\Users\jaspe\AppData\Local\Android\Sdk

当我弄清楚这一点时,我遇到了

这将在您的 Android SDK 中创建此文件夹:

...\Android\Sdk\cmdline-tools\latest\bin

现在使用 bin 目录中的 sdkmanager 接受所有许可:

C:\Users\jaspe\AppData\Local\Android\Sdk\cmdline-tools\latest\bin>sdkmanager.bat --licenses

Alright so I'm trying to build my React-Native app using Android Studio. I first ran into this error when building:

Failed to install the following Android SDK packages as some licences have not been accepted.
   build-tools;29.0.2 Android SDK Build-Tools 29.0.2
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

Using Android SDK: C:\Users\jaspe\AppData\Local\Android\Sdk

When figuring that out I came across this answer which told me to accept the licenses. However in trying to do so I got the following error:

C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager --licenses
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:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 5 more

To resolve which I found this post. I don't use brew, but I tried the second answer. It didn't work, sadly enough. Then I found out I didn't have a JDK installed, so I did that. But with the newest JDK installed I still get an exception:

C:\Users\jaspe\AppData\Local\Android\Sdk\tools\bin>sdkmanager.bat -licenses
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.xml.bind not found

And now I'm not sure what to do anymore. I found an answer explaining I needed to edit my project settings, but I think this doesn't apply to my project, and honestly I'm in a bit over my head. Does someone have experiences with these errors, and can help me fix them? I've spent the whole morning trying to figure this out, I'd expected building a runnable .APK as a demo would be easier...

解决方案

You are using the wrong sdkmanager, tools directory has been deprecated

Open Android Studio and install the latest command-line tools:

This will create this folder in your Android SDK:

...\Android\Sdk\cmdline-tools\latest\bin

Now use the sdkmanager which is inside the bin directory to accept all the licenses:

C:\Users\jaspe\AppData\Local\Android\Sdk\cmdline-tools\latest\bin>sdkmanager.bat --licenses

这篇关于“java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"接受 SDK 许可时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆