3

I am pretty new to ionic and I tried to build my app, but it failed, so I runned “cordova requirements” and I got this error:

$ cordova requirements
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.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 D:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle

Does anybody know how to fix this?

Thanks!

Jakub Balicki
  • 55
  • 1
  • 9

4 Answers4

1

This should fix it simply! As mentioned here https://stackoverflow.com/a/50097394/2642351 try installing JDK version less than 9, like JDK 8 or so. And update your JAVA_HOME path in the Environment Variables

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

Uninstall existing JDK which has version above 9.

Install this jdk (cordova works in jdk 8+) : https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-windows-x64.exe

0

You will have to use android sdk manager to download targets other then bundled by default. But before that check the android target version in your Ionic app.

You can launch the SDK Manager in one of the following ways:

From the Android Studio File menu: File > Settings > Appearance & Behavior > System Settings > Android SDK.

From the Android Studio Tools menu: Tools > Android > SDK Manager. From the SDK Manager icon (enter image description here) in the menu bar.

add the min and target version in config.xml

<platform name="android">

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

  <!--other line code -->

</platform>
Community
  • 1
  • 1
Vikram Palakurthi
  • 2,406
  • 1
  • 27
  • 30
0

For me below steps saved me

  1. Install the Android Studio 5.0 to 7.1 from menu: File > Settings > Appearance & Behavior > System Settings > Android SDK.

  2. Install JDK 8 +

  3. Set JAVA_HOME in system variables

  4. Restart machine

Zoe
  • 27,060
  • 21
  • 118
  • 148
Prashant Kanse
  • 772
  • 11
  • 23