0

I have been trying for hours to create a simple cordova project and somehow I cannot get past the building process. After installing all requirements (Java SDK, Gradle, Android Studio) and defining my environment variables I still get this error:

What I did so far:
cordova create Testproject com.example.hello Testproject
cd Testproject
cordova platform add android (10.1.1)

Then I wanted to check the "cordova requirements" command to check if I set everything up correctly and then this happened:

C:\Users\NAME\Desktop\TestProject>cordova requirements

Requirements check results for android:
Java JDK: installed 19.0.1
Android SDK: installed true
Android target: not installed
Command failed with exit code 1: avdmanager list target
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:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 5 more
Gradle: installed C:\gradle-6.9.3\bin\gradle.BAT
Some of requirements check failed

C:\Users\NAME\Desktop\TestProject>cordova build
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\NAME\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\NAME\AppData\Local\Android\Sdk
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\Users\NAME\Desktop\TestProject\platforms\android\settings.gradle'

* What went wrong:
Could not compile settings file 'C:\Users\NAME\Desktop\TestProject\platforms\android\settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 63

My settings.gradle file:

// GENERATED FILE - DO NOT EDIT
apply from: "cdv-gradle-name.gradle"
include ":"
include ":CordovaLib"
include ":app"

Java Version: 19.0.1
Cordova Version: 11.0.0
NPM Version: 7.15.0
Gradle Version: 6.9.3

(If you need anymore information, I am happy to provide them!)

What I did so far:
cordova create Testproject com.example.hello Testproject
cd Testproject
cordova platform add android (10.1.1)

Then I wanted to check the "cordova requirements" command to check if I set everything up correctly and then the error from above occured.

Pha4g
  • 17
  • 4
  • The classes from `javax.xml.bind` were removed from the jdk with jdk11. I believe your project still assumes a previous java version is used. – f1sh Nov 17 '22 at 15:51
  • Does this answer your question? [How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException](https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception) – f1sh Nov 17 '22 at 15:52
  • @f1sh sadly no, I tried adding this to my gradle file: " dependencies { // JAX-B dependencies for JDK 9+ implementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2" } " but I still get the error. – Pha4g Nov 17 '22 at 16:04
  • have you installed any plugin yet? it won't work with JDK version beyond 11. Also, upgrade your gradle version and overall android studio ..see the documentation here https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html – Riya Singh Nov 18 '22 at 13:44

1 Answers1

0

With Cordova version 11.0.0, I got it working by downgrading from Java 19 to java 11. Java Development Kit (JDK)

You could try using java version 11

mkspeter3
  • 51
  • 2
  • 7