我正在尝试在计算机上安装Nativescript CLI,并且已经完成了网站上概述的所有步骤。运行tns doctor
时,得到以下输出:
C:\WINDOWS\system32>tns doctor
√ Getting environment information
TIP: To avoid setting up the necessary environment variables, you can use the chocolatey package manager to install the Android SDK and its dependencies.
There seem to be issues with your configuration.
√ Getting NativeScript components versions information...
√ Component nativescript has 6.0.1 version and is up to date.
√ Your ANDROID_HOME environment variable is set and points to correct directory.
√ The Android SDK is installed.
√ Javac is installed and is configured properly.
√ The Java Development Kit (JDK) is installed and is configured properly.
√ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
× WARNING: adb from the Android SDK is not installed or is not configured properly.
For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements
× Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK 28 or later.
Run `$ sdkmanager` to manage your Android SDK versions.
× You need to have the Android SDK Build-tools installed on your system. You can install any version in the following range: '>=23 <=28'.
Run `$ sdkmanager` from your command-line to install required `Android Build Tools`. In case you already have them installed, make sure `ANDROID_HOME` environment variable is set correctly.
我已经运行echo %JAVA_HOME%
和echo %ANDROID_HOME%
,并收到以下结果:C:\Program Files\Java\jdk-12.0.1
和C:\Android\android-sdk
。
运行sdkmanager
时,我得到以下信息:
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:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more
我已经检查了我的JAVA_HOME和ANDROID_HOME环境变量,它们是正确的并且与cmd输出匹配。
我还尝试了卸载并重新安装Nativescript CLI。我得到了完全相同的结果。
是否可以安装Android Studio导致此问题?
答案 0 :(得分:0)
我相信问题出在您所安装的Java版本上。 This帖子详细讨论了此问题。 sdkmanager
似乎与Java新版本有关。
最简单的解决方法可能是降级到Java8。如果不想降级到Java 8,可以尝试设置一些Java选项,如上面的文章所述。
答案 1 :(得分:0)
现在回答还为时已晚,但希望此解决方案能对其他人有所帮助。
当我使用Nativescript开发应用程序并使用我的android设备进行测试时,遇到了相同的问题
在调试并重新安装所有内容之后,我决定首先测试 adb
因此,我测试了命令adb devices
,结果以错误结束:
adb.exe F 01-27 22:35:19 6364 9128 fdevent_poll.cpp:64] failed to create fdevent interrupt socketpair: Invalid argument
我找到了针对上述问题here的解决方案
netsh winsock reset
重置winsock之后,我终于能够解决我的问题。