apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Unsupported class file major version 64 when running Cordova with Gradle 8.2.1 #1639

Closed JoraSN closed 9 months ago

JoraSN commented 9 months ago

Bug Report

Problem

What is expected to happen?

I expected to build and run my Cordova project on Android using the command cordova run android --target=Pixel_3a_API_33_x86_64 successfully.

What does actually happen?

Instead, I encountered the following error during the build process:

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\user\Desktop\Cordova_Apps\Crime_Map_App\platforms\android\settings.gradle' (C:\Users\user\.gradle\caches\7.6\scripts\dqjrgsw17c62wbpoagod92e1e).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 64

* 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 10s
Command failed with exit code 1: C:\Users\user\Desktop\Cordova_Apps\Crime_Map_App\platforms\android\gradlew -b C:\Users\user\Desktop\Cordova_Apps\Crime_Map_App\platforms\android\build.gradle cdvBuildDebug

Information

The error message mentions an unsupported class file major version 64. I am using Cordova version 12.0.0 with Cordova Android platform version 12.0.0. The Gradle version on my system is 8.2.1, and I have Java version 20.0.1 set up.

Command or Code

To reproduce the issue, make a new Cordova project, add android as a platform and run the following command in the command prompt or terminal:

cordova run android --target=Pixel_3a_API_33_x86_64

With "Pixel_3a_API_33_x86_64" being the name of your emulator.

Environment, Platform, Device

I am experiencing the issue on a Windows 11 machine.

Version information

Cordova CLI version: 12.0.0 Cordova Android platform version: 12.0.0 Gradle version: 8.2.1 Java version: 20.0.1 Operating System: Windows 11

Checklist

breautek commented 9 months ago

Gradle doesn't support java 20. Gradle 8 itself supports up to java 19.

However, cordova android is using Android Gradle Plugin 7.4.2/ gradle 7 which is intended to be ran with java 11. Java 11 would be the current recommended version to use.