Joh*_*hly 2 java macos android build gradle
我束手无策,试图让它发挥作用,但没有找到解决方案。我刚刚将 Android Studio 升级到 Arctic Fox,但收到此错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_core:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
Run Code Online (Sandbox Code Playgroud)
我在 macOS BiGSur 11.2.3 上运行。
我打开终端并运行/usr/libexec/java_home -V | grep jdk
哪个输出:
Matching Java Virtual Machines (1):
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Run Code Online (Sandbox Code Playgroud)
我尝试~/.zshrc通过添加各种导出行进行编辑,例如:
export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
Run Code Online (Sandbox Code Playgroud)
运行后我在终端中收到此错误source ~/.zscrc:
.zshrc:export:2: not valid in this context: Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Run Code Online (Sandbox Code Playgroud)
并尝试了这个:
export JAVA_HOME=$(/usr/libexec/java_home)
Run Code Online (Sandbox Code Playgroud)
这只是重复相同的构建失败。
我还尝试向 Gradle.properties 文件添加各种路径,例如以下之一:
org.gradle.java.home=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)
第一个和Value '/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)第二个构建失败相同。
我在我的系统上搜索了tools.jar,但没有找到任何内容。
还尝试卸载 Java 并重新安装它......什么也没有。
请问还有其他建议吗?
终于找到答案了。显然我只安装了JRE,没有安装JDK。修复步骤:
重新运行/usr/libexec/java_home -V | grep jdk获取新路径,输出:
Matching Java Virtual Machines (2):
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_301 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)
将 Java SE 8 路径添加到 android > gradle.properties:org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
重建应用程序。
希望在我花了 5 个小时试图解决这个问题之后这对其他人有所帮助。
| 归档时间: |
|
| 查看次数: |
4160 次 |
| 最近记录: |