android新项目报错-gradle和jdk的兼容问题

474 阅读1分钟

前提:

系统默认jdk的版本是1.8,新建项目时默认的gradle是8.9版本。由于项目普遍使用6.8.2或者是7.4版本的gradle,故改为6.8.2。编译!

报错:

此时编译报错:

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 6.8.2. Cannot sync the project.

Your build is currently configured to use incompatible Java 21.0.3 and Gradle 6.8.2. Cannot sync the project.

We recommend upgrading to Gradle version 8.9.

The minimum compatible Gradle version is 8.5.

The maximum compatible Gradle JVM version is 15.

Possible solutions:
 - Upgrade to Gradle 8.9 and re-sync
 - Upgrade to Gradle 8.5 and re-sync

经排查,是在File-Setting-Build-Build Tools-Gradle中修改gradle jdk,指定为11