flutter报错You are currently using Java 1.8

129 阅读1分钟

flutter报错Could not run phased build action using connection to Gradle distribution 'services.gradle.org/distributio…: 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了 image.png

但是它识别到的还是1.8 image.png 把gradle的jdk改掉就行了

打开android studio无法指定jdk版本 image.png

直接指定系统JAVA_HOME变量就可以 image.png 再执行gradle -v,如果你发现还是1.8,就说明用户变量里面以前配过jdk image.png 新建项目才会生效