cordovaandroid-gradle-pluginquasar

Build error when running cordova project on quasar


I am trying to do "quasar build -m android" according to documentation https://quasar.dev/quasar-cli-vite/developing-cordova-apps/build-commands#building-for-production I followed the preparation instructions https://quasar.dev/quasar-cli-vite/developing-cordova-apps/preparation, all system variables are specified and paths are specified https://i.sstatic.net/FPKt2.png https://i.sstatic.net/iRegi.png

The documentation states that Gradle version 4.10.3 is required, the Java download link suggests installing version 8. Under these conditions, if I execute "cordova requirements" from the project's "src-cordova" folder, then I get no errors

PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova requirements                      

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-34,android-UpsideDownCakePrivacySandbox,android-TiramisuPrivacySandbox,android-33,android-28,android-27,android-26
Gradle: installed C:\Program Files\Gradle\gradle-4.10.3\bin\gradle.BAT

But when doing a build via "cordova build --release --warning-mode=all" I get the following errors

PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova build --release --warning-mode=all
Checking Java JDK and Android SDK versions
ANDROID_HOME=C:\Users\Maksim\AppData\Local\Android\Sdk (recommended setting)
ANDROID_SDK_ROOT=C:\Users\Maksim\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\Maksim\AppData\Local\Android\Sdk
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'lmschat.1t'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.2.
     Required by:
         project :
      > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.6')

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
Command failed with exit code 1: C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova\platforms\android\gradlew -b C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova\platforms\android\build.gradle :app:bundleRelease                    

Then I upgrade the Java version to 11 for compatibility (https://docs.gradle.org/current/userguide/compatibility.html), change the system variable path, but when doing "cordova requirements" I get this:

PS C:\Users\Maksim\Desktop\lmschat-mobile\src-cordova> cordova requirements

Requirements check results for android:
Java JDK: installed 11.0.18
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:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 5 more
Gradle: installed C:\Program Files\Gradle\gradle-4.10.3\bin\gradle.BAT
Some of requirements check failed

What am I doing wrong?

After running "cordova build --release --warning-mode=all" an APK file should be generated. It's not happening now


Solution

  • I tried using Capacitor (quasar.dev/quasar-cli-vite/developing-capacitor-apps/…) and without changing the configuration files, I was able to build without errors