Android Gradle 插件需要 Java 11 到 运行。您当前使用的是 Java 1.8,但我使用的是 java 11
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8, but i'm using java 11
我导入了一个 Flutter 项目,当我尝试 运行 它时,我收到了这条消息错误:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/omer358/FlutterProjects/MyProjects/ConverterNOW/android/app/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
* 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
BUILD FAILED in 22s
Exception: Gradle task assembleDebug failed with exit code 1
我搜索了一些解决方案,其中之一建议我使用 java1.8,但事实并非如此!
omer358@OMO:~/FlutterProjects/MyProjects/ConverterNOW/android$ ./gradlew --version
------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.14 (Ubuntu 11.0.14+9-Ubuntu-0ubuntu2.22.10)
OS: Linux 5.13.0-35-generic amd64
你能帮我走开吗!
你的位置布置好了吗?
是不是gradlejava版本太低
JAVA_HOME D:\Android\Android Studio\jre
%JAVA_HOME%\bin
我遇到了同样的问题,但我所做的是删除 android 文件夹并再次 运行 。如果您使用的是 android studio,请在您的终端中通过此 Flutter create .,它将使用您指定的 SDK 来构建 android 项目
headache-less解决方法:
只需卸载您的(旧)版本 android studio,访问他们的网站,然后安装最新版本。这应该会自动将您的 java 版本更新为您的 Flutter 项目所需的任何版本。
在尝试了很多其他方法后对我有用。
我导入了一个 Flutter 项目,当我尝试 运行 它时,我收到了这条消息错误:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/omer358/FlutterProjects/MyProjects/ConverterNOW/android/app/build.gradle' line: 24
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
* 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
BUILD FAILED in 22s
Exception: Gradle task assembleDebug failed with exit code 1
我搜索了一些解决方案,其中之一建议我使用 java1.8,但事实并非如此!
omer358@OMO:~/FlutterProjects/MyProjects/ConverterNOW/android$ ./gradlew --version
------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.14 (Ubuntu 11.0.14+9-Ubuntu-0ubuntu2.22.10)
OS: Linux 5.13.0-35-generic amd64
你能帮我走开吗!
你的位置布置好了吗?
是不是gradlejava版本太低
JAVA_HOME D:\Android\Android Studio\jre
%JAVA_HOME%\bin
我遇到了同样的问题,但我所做的是删除 android 文件夹并再次 运行 。如果您使用的是 android studio,请在您的终端中通过此 Flutter create .,它将使用您指定的 SDK 来构建 android 项目
headache-less解决方法:
只需卸载您的(旧)版本 android studio,访问他们的网站,然后安装最新版本。这应该会自动将您的 java 版本更新为您的 Flutter 项目所需的任何版本。
在尝试了很多其他方法后对我有用。