【问题标题】:adb from the Android SDK is not installed or is not configured properly on Windows 10Android SDK 中的 adb 未安装或未在 Windows 10 上正确配置
【发布时间】:2019-07-21 15:36:36
【问题描述】:

我正在尝试在我的计算机上安装 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.1C:\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 可能会导致此问题吗?

【问题讨论】:

    标签: android nativescript


    【解决方案1】:

    现在回答为时已晚,但希望此解决方案对其他人有所帮助。

    当我在 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后,我终于可以解决我的问题了。

    【讨论】:

      【解决方案2】:

      我认为问题出在您安装的 Java 版本上。 This 帖子详细讨论了这个问题。 sdkmanager 似乎对较新的 Java 版本有问题。

      最简单的解决方法可能是降级到 Java 8。如果您不想降级到 Java 8,可以尝试设置一些 Java 选项,如上面的帖子中所述。

      【讨论】:

      • 这似乎有助于揭示问题所在,但仍有一个问题我无法弄清楚。我已经编辑了我的帖子以反映。鉴于结果,我认为可以肯定地说问题不在于我的 Java。而是我的 Android 或 Nativescript CLI。
      • 我认为问题可能出在您安装的 Java 版本上。我在sdkmanager 上遇到过类似的问题,我通过返回Java 8 This 详细讨论了这个问题来解决这个问题。
      【解决方案3】:

      在我自己的 Windows 10 案例中,我没有正确设置 ANDROID_HOME 用户变量的路径,而且我必须在 Android Studio 中设置一个新的 AVD 设备。

      • 设置 ANDROID_HOME 用户变量

        注意:默认情况下,我的 android SDK 位于 C:\Users\&lt;system-user-name&gt;\AppData\Local\Android\Sdk另外一种确认Android SDK安装路径的方法如下:

              i. Open Android Studio
              ii. Navigate to File -> Settings -> System Settings -> Android SDK
              iii. There you will see the Android SDK Location
        

        确认 SDK 的路径后,将 ANDROID_HOME 添加到 Windows 10 上的 Windows 用户变量中:

              i. Clicking start and searching for "System environment Variable".
              ii. Click the first search result  "Edit the System environment Variables".
              iii. In the System Properties Dialog Box click the "Environment Variables" Button.
              iv. In Environment Variables Dialog Box, Click the "New" button under the User variables.
               v. Add the variable name "ANDROID HOME" and the path  "C:\Users\<system-user-name>\AppData\Local\Android\Sdk"
              vi. After Saving the settings, it is recommended to reboot the computer.
        
      • 在 Android Studio 中设置 AVD

              i. Open Android Studio
              ii. Navigate to Tools -> Device Manager -> System Settings -> Android SDK
              iii. Click the `Create New Device` button.
              iv. Configure the device to your requirements and click finish to complete your settings. Exist Android Studio after you are done configuring.
        

      【讨论】:

        猜你喜欢
        • 2020-07-16
        • 1970-01-01
        • 1970-01-01
        • 2020-12-24
        • 1970-01-01
        • 2017-05-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多