flutter报错Could not run phased build action using connection to Gradle distribution ‘https://services.gradle.org/distributions/gradle-7.6.3-all.zip’.\r\norg.gradle.api.ProjectConfigurationException: A problem occurred configuring root project ‘android’.\r\nA problem occurred configuring root project ‘android’.\r\nA problem occurred evaluating root project ‘android’.\r\nA problem occurred configuring project ‘:app’.\r\nBuild file ‘’ line: 2\r\nAn exception occurred applying plugin request [id: ‘com.android.application’]\r\nFailed to apply plugin ‘com.android.internal.application’.\r\nAndroid Gradle plugin requires Java 11 to run. You are currently using Java 1.8.\n Your current JDK is located in C:\Program Files\Java\jdk1.8.0_321\jre\n You can try some of the following options:\n - changing the IDE settings.\n - changing the JAVA_HOME environment variable.\n - changing org.gradle.java.home
in gradle.properties
.
可以看到本机已经升级到java17了
但是它识别到的还是1.8
把gradle的jdk改掉就行了
打开android studio无法指定jdk版本
直接指定系统JAVA_HOME
变量就可以
再执行gradle -v
,如果你发现还是1.8,就说明用户变量里面以前配过jdk
新建项目才会生效