Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4.

报错信息
Unsupported Java. 
Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4.

Possible solution:
 - Upgrade Gradle wrapper to 7.2 version and re-import the project

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第1张图片

Could not open cp_init remapped class cache for dw5ezsq9vnujkjvxyvhfx35dd (C:\Users\lenovo\.gradle\caches\5.6.4\scripts-remapped\ijmapper_39sxepuidel0xqznotomv6j9k\dw5ezsq9vnujkjvxyvhfx35dd\cp_initb88fbed980d87867994e661e74c75e1f).
> Could not open cp_init generic class cache for initialization script 'C:\Users\lenovo\AppData\Local\Temp\ijmapper.gradle' (C:\Users\lenovo\.gradle\caches\5.6.4\scripts\dw5ezsq9vnujkjvxyvhfx35dd\cp_init\cp_initb88fbed980d87867994e661e74c75e1f).
   > Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.cache.CacheOpenException: Could not open cp_init remapped class cache for dw5ezsq9vnujkjvxyvhfx35dd (C:\Users\lenovo\.gradle\caches\5.6.4\scripts-remapped\ijmapper_39sxepuidel0xqznotomv6j9k\dw5ezsq9vnujkjvxyvhfx35dd\cp_initb88fbed980d87867994e661e74c75e1f).
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:80)
	at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:42)
	at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFactory.java:95)
	at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactory.java:68)
	at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuilder.open(DefaultCacheRepository.java:126)
	at 
	... 135 more

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第2张图片

错误原因

因为项目所需的gradle5.6.4对应的是java8,而Android Studio Flamingo | 2022.2.1 Patch 1自带的java版本为17,它会使用默认的java版本去编译项目,所以编译时导致报错。

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第3张图片

解决方法

1、安装jdk1.8:Win10如何安装JDK1.8,最快最详细教程

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第4张图片

2、安装并配置好环境后,输入命令查看是否安装成功,如下信息为成功。

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第5张图片

3、进入Gradle配置,选择Gradle JDK,可以看到检测到了我们的jdk1.8,选中它。

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第6张图片
4、点击Apply,点击OK,然后再次同步项目。

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第7张图片

5、同步过程中,会出现Windows安全提示,选择允许jdk1.8访问。

Your build is currently configured to use Java 17.0.6 and Gradle 5.6.4._第8张图片

不要跟不讲理的人争论,否则就中了她的招,因为她一直认为自己是对的,最后生气的是自己。

你可能感兴趣的:(Android经验,java,android,android,studio,安卓,gradle)