6

Using cordova on WINDOWS 10 I'm not able to build project.

When I tried cordova requirements it shows me Android target: not installed.

I tried all possible solutions over internet and SO, however, none worked for me. Probably this is related to the latest version of cordova v 8.0.0.

I tried the following which did NOT work:
1. overwriting tools folder from cordova CLI in my C:\Users\admin\AppData\Local\Android\Sdk folder.
2. cordova platform remove android and then cordova platform add android@7.0.0
3. Uninstalling and reinstalling all SDKs in Android Studio.
4. <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
5. Updated config.xml file with

<platform name="android">

  <preference name="android-minSdkVersion" value="16"/> 
  <preference name="android-targetSdkVersion" value="26"/>

  <!--other line code -->

</platform>
  1. Installed all SDK from SDK manager in Android Studio from 16 to 27.

Following is the log after firing the requirements command:

Android Studio project detected

Requirements check results for android:
Java JDK: installed
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output:
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.parseSdk(AvdManagerCli.java:328)
        at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:204)
        at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:195)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 6 more
Gradle: installed

Please suggest a solution to fix this issue.

Temp O'rary
  • 5,366
  • 13
  • 49
  • 109

1 Answers1

15

Finally I fixed it! I downgraded my JDK to version 8.172. Seems like JDK version above 8 is not supported by Android SDK. Then, update your JAVA_HOME path in the Environment Variables to point to the new JDK folder path. If you are using Mac or *nix boxes, you may also try jenv as well (I could not try jenv, but let me know if it did work for you)

Temp O'rary
  • 5,366
  • 13
  • 49
  • 109
  • 2
    Thanks so much. I would have never thought to downgrade jdk versions – Ashley Jul 11 '18 at 13:13
  • 1
    Why was this so hard?!? I just spent 2 hours troubleshooting this on macOS Mojave. Following your advice, I found an archived JDK version named `jdk-8u172-macosx-x64.dmg` on Oracle's website, installed that, and voila, `cordova requirements` are satisfied! – Bungle Feb 13 '19 at 05:46