且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在我的“gradle build"中遇到“org.gradle.api.ProjectConfigurationException"错误

更新时间:2023-01-01 09:43:41

我能够通过读取 gradle 守护进程的输出日志来解决这个问题,下面是帮助我修复它的相关行.

I was able to solve this issue by reading the output log from the gradle daemon and below is the relevant line that helped me fix it.

14:52:50.575 [INFO] [org.gradle.launcher.daemon.server.Daemon] start()调用守护进程 -DefaultDaemonContext[uid=03e55abd-dc5a-42c5-bc7f-fc25f6a78bcb,javaHome=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home,daemonRegistryDir=/Users/user_name/.gradle/daemon,pid=16809,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]

14:52:50.575 [INFO] [org.gradle.launcher.daemon.server.Daemon] start() called on daemon - DefaultDaemonContext[uid=03e55abd-dc5a-42c5-bc7f-fc25f6a78bcb,javaHome=/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home,daemonRegistryDir=/Users/user_name/.gradle/daemon,pid=16809,idleTimeout=10800000,daemonOpts=-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]

因此,要点是 gradle 设置和 Android Studio 设置彼此独立工作.当 org.gradle.java.home 未在属性中显式设置时,Gradle 在启动守护程序并进行构建时依赖 JAVA_HOME 环境变量.

So, the gist is that the gradle settings and Android Studio settings work independent of each other. Gradle relies on the JAVA_HOME env var while starting up a daemon and making your build, when org.gradle.java.home isn't explicitly set in properties.

因此,当回滚到不同的 JVM 时,请确保将 JAVA_HOME 环境变量设置为特定的 JVM(如果您在所有应用程序中使用相同的 JVM)或在 gradle 中设置如下所示的守护程序特定设置.properties 文件在项目级别可见:

Therefore, when rolling back to a different JVM, make sure to set the JAVA_HOME env var to that specific JVM (if you use the same JVM across all your applications) or set daemon specific setting like below in your gradle.properties file visible at the project level :

org.gradle.java.home=/Library/Java/JavaVirtualMachines/<jdk_version>/Contents/Home

请注意,以上是我的路径,我使用的是 Mac.在其他平台上可能会有所不同.