cordova gradle build SUCCESSFUL and then turns into FAILED. Maybe something is wrong with the versions? It seems to download a lower gradle version in the middle... why?
Starting with versions: Gradle 7.3.3, Cordova 10.0.0, Java/JDK 17.0.2 - Here is the transcript (leaving only the main things):
C:\MYAPP\Project>cordova build android –release
(node:10944) ExperimentalWarning: The fs.promises API is experimental
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\USER\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\USER\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\USER\AppData\Local\Android\Sdk
Starting a Gradle Daemon (subsequent builds will be faster)
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.3.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 9s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Downloading https://services.gradle.org/distributions/gradle-7.1.1-all.zip
Welcome to Gradle 7.1.1!
Here are the highlights of this release:
Faster incremental Java compilation
Easier source set configuration in the Kotlin DSL
For more details see https://docs.gradle.org/7.1.1/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
Where:
Settings file 'C:\MYAPP\Project\platforms\android\settings.gradle'
What went wrong:
Could not compile settings file 'C:\MYAPP\Project\platforms\android\settings.gradle'.
startup failed:
General error during conversion: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
[LONG LIST OF LOCATIONS]
1 error
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.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 36s
Command failed with exit code 1: C:\MYAPP\Project\platforms\android\gradlew :app:bundleRelease -b C:\MYAPP\Project\platforms\android\build.gradle
CodePudding user response:
First Successful build means successful execution of gradle wrapper. Its task was to download the gradle 7.1.1. The second build (the build you want to execute) ends with failure, because of your gradle jvm version. If you are using IntelliJ IDEA, open gradle settings(this may be on the left part of your screen) or just open preferences > Build, Execution, Deployment > Build Tools > Gradle and set the Gradle JVM
CodePudding user response:
After struggling for hours to find the correct versions, it appears that the following combination seems to build successfully:
cordova 10.0.0
jdk 11.0.13
Gradle 7.1.1
Android Gradle Plugin 4.2.2
There were many other problems, overcome with the help of other discussions on the web. I kept a record of them, if anyone is interested.