Intellij Idea日志GradleConnectionException:无法在构建时使用Gradle安装执行构建

时间:2014-06-04 04:16:51

标签: android intellij-idea gradle android-gradle build.gradle

我使用Intellij Idea 13.1.1并在构建时获得GradleConnectionException:

Error:org.gradle.tooling.GradleConnectionException:
Could not execute build using Gradle installation 'C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10'.:
Could not execute build using Gradle installation 'C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10'.

我在这里看到过类似的问题并用Google搜索。但它没有帮助我。

最后我找到了Idea的buld日志,这是一个例外,其中有更多细节(抱歉很长的日志,但它只是为了获得更详细的信息):

2014-06-04 10:41:20,732 [      0]   INFO - jps.cmdline.JpsModelLoaderImpl - Loading model: project path = <PATH_TO_MY_PROJECT>, global options path = C:/Users/<USER_NAME>/.IdeaIC13/config/options 
2014-06-04 10:41:21,404 [    672]   INFO - jps.cmdline.JpsModelLoaderImpl - Model loaded in 673 ms 
2014-06-04 10:41:21,404 [    672]   INFO - jps.cmdline.JpsModelLoaderImpl - Project has 3 modules, 14 libraries 
2014-06-04 10:41:21,643 [    911]   INFO - ellij.util.io.PagedFileStorage - lower=100; upper=200; buffer=10; max=688586752 
2014-06-04 10:41:22,288 [   1556]   INFO - .incremental.IncProjectBuilder - Building project; isRebuild:false; isMake:true parallel compilation:false 
2014-06-04 10:41:22,292 [   1560]   INFO - r.api.ClassFilesIndicesBuilder - class files data index disabled 
2014-06-04 10:41:22,329 [   1597]   INFO - penapi.util.io.win32.IdeaWin32 - Native filesystem for Windows is operational 
2014-06-04 10:41:22,456 [   1724]   INFO - der.AndroidGradleTargetBuilder - Using execution settings: BuilderExecutionSettings[embeddedGradleDaemonEnabled=false, buildMode=SOURCE_GEN, gradleDaemonMaxIdleTimeInMs=60000, gradleDaemonCommandLineOptions=[], gradleDaemonJvmOptions=[], gradleHomeDir=C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10, gradleServiceDir=null, javaHomeDir=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\jre\jre, offlineBuild=false, parallelBuild=false, projectDir=<PATH_TO_MY_PROJECT>, verboseLoggingEnabled=false, modulesToBuildNames=[<PROJECT_NAME>, <PROJECT_NAME>-<PROJECT_NAME>, <PROJECT_NAME_SAMPLE>]] 
2014-06-04 10:41:22,458 [   1726]   INFO - der.AndroidGradleTargetBuilder - Gradle build using tasks: [:<PROJECT_NAME>:generateDebugSources, :<PROJECT_NAME_SAMPLE>:generateDebugSources] 
2014-06-04 10:41:22,460 [   1728]   INFO - der.AndroidGradleTargetBuilder - About to build project '<PROJECT_NAME>' located at <PATH_TO_MY_PROJECT> 
2014-06-04 10:41:22,537 [   1805]   INFO - der.AndroidGradleTargetBuilder - Passing JVM args to Gradle Tooling API: [-Dandroid.home=C:\adt-bundle-windows-x86_64-20131030\sdk] 
2014-06-04 10:41:24,934 [   4202]   INFO - .incremental.IncProjectBuilder - org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation 'C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10'. 
org.jetbrains.jps.incremental.ProjectBuildException: org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation 'C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10'.
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:877)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:772)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:595)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:352)
    at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:184)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:224)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:133)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation 'C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10'.
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
    at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
    at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:67)
    at com.android.tools.idea.jps.builder.AndroidGradleTargetBuilder.doBuild(AndroidGradleTargetBuilder.java:331)
    at com.android.tools.idea.jps.builder.AndroidGradleTargetBuilder.build(AndroidGradleTargetBuilder.java:131)
    at com.android.tools.idea.jps.builder.AndroidGradleTargetBuilder.build(AndroidGradleTargetBuilder.java:76)
    at org.jetbrains.jps.incremental.BuildOperations.buildTarget(BuildOperations.java:101)
    at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:819)
    at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:857)
    ... 14 more
Caused by: org.gradle.launcher.daemon.client.DaemonConnectionException: The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch: 
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\jre\jre,daemonRegistryDir=C:\Users\<USER_NAME>\.gradle\daemon,pid=1644,idleTimeout=null,daemonOpts=-Dfile.encoding=windows-1251]
Actual: DefaultDaemonContext[uid=bb72a914-1081-4f81-a9b1-67c8d0a9106d,javaHome=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\jre,daemonRegistryDir=C:\Users\<USER_NAME>\.gradle\daemon,pid=5592,idleTimeout=60000,daemonOpts=-Dfile.encoding=windows-1251]

    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connectToDaemonWithId(DefaultDaemonConnector.java:119)
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:99)
    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:72)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:149)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
    at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
    at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
    at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
    at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
    at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
    at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:93)
    at org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:133)
    at org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedModelProducer.produceModel(ModelBuilderBackedModelProducer.java:44)
    at org.gradle.tooling.internal.consumer.connection.GradleBuildAdapterProducer.produceModel(GradleBuildAdapterProducer.java:42)
    at org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection.run(ModelBuilderBackedConsumerConnection.java:50)
    at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:77)
    at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:71)
    at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
    at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
    at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    ... 3 more

有什么想法吗?

更新

此目录存在:

C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\jre\jre

我有JAVA_HOME变量

C:\Java\jdk1.7.0_45

此外,我在

中有2个gradle.properties个文件
C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10\samples\userguide\tutorial\properties\gradle.properties

C:\Users\<USER_NAME>\.gradle\wrapper\dists\gradle-1.10-all\6vpvhqu0efs1fqmqr2decq1v12\gradle-1.10\samples\signing\maven\gradle.properties

我试图将org.gradle.java.home=C:/Java/jdk1.7.0_45放入其中,但它对我没有帮助。

我做错了什么?

3 个答案:

答案 0 :(得分:6)

在“平台设置”中检查JDK主路径。

在我的情况下,它有额外的&#39; / jre&#39;后缀,导致与您描述的相同的错误。

Configuring JDK home path

答案 1 :(得分:0)

我不知道为什么守护程序试图使用来自C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.1.1\jre\jre的Java(是否有这样的目录),但问题可能与{{1}中的JAVA_HOME env变量或org.gradle.java.home有关}。 http://forums.gradle.org/gradle/topics/gradle_daemon_different_context可以为您提供一些如何解决问题的提示。

答案 2 :(得分:0)

我使用JDK 1.7.0_71收到此错误。

恢复使用旧的1.7.0_60修复它。