英文:
How to fix Android Studio Flamingo asking to use Java 11 to run on MacOS?
问题
我安装了最新版的Android Studio Flamingo并尝试运行一个Flutter代码项目,但遇到了以下错误代码:
无法应用插件 'com.android.internal.application'。
> Android Gradle插件需要Java 11才能运行。您当前正在使用Java 1.8。
我尝试了在stackoverflow上发布的解决方案,但我的Android Studio没有Gradle JDK选择选项。请问有谁可以帮忙吗?
英文:
I did a fresh install of the Android Studio Flamingo and tried to run a flutter code project but encounter this error code.
Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
I tried the solutions posted on stackoverflow but my Android Studio does not have the Gradle JDK selection option
Can anyone help?
答案1
得分: 2
以下是翻译好的部分:
我遇到了一个略有不同的问题,但我认为解决方法可能是相同的。
我遇到的错误是“class file major version 61”,在阅读了这篇文章之后,我明白我需要将我的项目编译为Java 11,我认为这也会解决你的问题。
修复步骤:
- 下载Java 11 -
brew install openjdk@11
- 将它创建符号链接到你的JVM文件夹 - 在上述命令的输出中,找到“For the system Java wrappers to find this JDK, symlink it with <command>” - 运行这个命令
- 在
android/gradle.properties
中添加一行org.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
好处在于你并没有改变你的Java主目录或其他项目所需的Java 1.8版本,你只是告诉这个项目要使用Java 11进行编译。
英文:
I faced a slightly different problem, but I think the resolution could be the same.
The error I had was "class file major version 61", and after reading this, I understood I needed my project to compile with Java 11, and I think that will resolve your issue as well.
Steps to fix:
- Download java11 -
brew install openjdk@11
- Symlink it to your JVM folder - In the output of the above command, find "For the system Java wrappers to find this JDK, symlink it with <command>" - run this command
- In
android/gradle.properties
, add lineorg.gradle.java.home=/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
The good thing here is that you aren't changing your java home value or anything so if you need java 1.8 for other projects that's fine, you're just telling this project to compile with 11
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论