ObscurityGamer
ObscurityGamer

Reputation: 35

adb from the Android SDK is not installed or is not configured properly on Windows 10

I'm trying to install Nativescript CLI on my computer, and I've gone through all the steps outlined on the website. When I run tns doctor, I get the following output:

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.

I have run echo %JAVA_HOME% and echo %ANDROID_HOME% and received the following results: C:\Program Files\Java\jdk-12.0.1 and C:\Android\android-sdk.

When I run sdkmanager, I get the following:

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

I have checked my JAVA_HOME and ANDROID_HOME environment variables, and they are correct and match the cmd output.

I have also tried uninstalling and reinstalling Nativescript CLI. I got the exact same results.

Could having Android Studio installed potentially cause this issue?

Upvotes: 2

Views: 4915

Answers (3)

Dev
Dev

Reputation: 441

In my own case on Windows 10, I didn't set the path to the ANDROID_HOME user variable correctly and also I had to setup a new AVD Device in Android Studio.

  • Setting Up ANDROID_HOME user variable

    Note: By default my android SDK was located at C:\Users\<system-user-name>\AppData\Local\Android\Sdk Another way to confirm the path to Android SDK installation is as follows:

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

    After confirming the path to the SDK add ANDROID_HOME to your Windows User Variables on Windows 10 by:

          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.
    
  • Setting AVD in Android Studio

          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.
    

Upvotes: 0

Muhammad Ali Shahzad
Muhammad Ali Shahzad

Reputation: 84

Its too late to answer but hope this solution will help others.

While I was developing application in Nativescript and using my android device for testing I ran into same same issue of enter image description here

After debugging and reinstalling everything I decided to test adb first so, I tested command adb devices and it end up with error:

adb.exe F 01-27 22:35:19 6364 9128 fdevent_poll.cpp:64] failed to create fdevent interrupt socketpair: Invalid argument

I found solution for above issue here netsh winsock reset

after resetting winsock I finally able to resolve my issue.

Upvotes: 1

Abhilash G
Abhilash G

Reputation: 86

I believe the issue is with the Java version that you have installed. This post talks about this issue in detail. sdkmanager seems to have issues with newer Java versions.

The easiest fix might be to downgrade to Java 8. If you don't want to downgrade to Java 8 you can try setting a few java options as mentioned in the post above.

Upvotes: 0

Related Questions