Reputation: 478
I tried to setup Ionic+Cordova for the Android platform. I installed JDK, Android SDK etc. but running cordova requirements
gives me:
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.run(AvdManagerCli.java:213)
at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
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:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 5 more
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin\gradle
Upvotes: 7
Views: 10033
Reputation: 133
These answers are outdated. The current version of Cordova uses JDK 11. I had this error on my windows 11 laptop and it took me a while to track it down. In the Windows environment variables, check the Path values in both:
I found that I had multiple JDK path values in the System "Path" variable that were causing problems. I deleted all of them except the correct JDK path and it fixed the issue. More details here: https://wastedpotential.com/fix-for-cordova-error-android-target-not-installed-cmd-command-failed-with-exit-code-1/
Upvotes: 1
Reputation: 37
You need to check your JDK version. Cordova upto version 9 only support java 8, in version 10 you can use java 11 You can download previous version by login oracle.com and searching the version 8 JDK. Once you install JDK then set the system variable in 'User' as JAVA_HOME and path of your JDK. also set for ANDROID_HOME by following this guide.
Some times , Environment variables need PC reboot to take effect.
Now go to go to the app folder and check cordova requirements. Hope this help
Upvotes: 1
Reputation: 784
Change your "jdk any version" to "1.8.any version". In short Cordova requires you to have jdk 1.8 installed.
Upvotes: 0
Reputation: 71
Check your JDK version? I used JDK9 that was making the same error. After installation JDK 8 error disappeared.
Upvotes: 2
Reputation: 85
This means that the emulator your are trying to run your app in is not running. You need to install or run this emulator. Try running the emulator first, for example on my end it looks like this:
Upvotes: 6