gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().

使用 sdk 命令安装完成 gradle 之后,执行 gradle 命令时提示以下信息:

$ gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 4s

这个错误的原因是什么呢?

我们可以根据命令的提示,为命令添加参数来查看具体原因:

$ gradle --info --debug --stacktrace
15:57:33.072 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: /Users/aven/.gradle/native
15:57:35.406 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Executing build 07ab7349-26c5-488b-a050-da26c9dba9c0.1 in daemon client {pid=6689}
15:57:35.430 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface utun0
15:57:35.430 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
15:57:35.430 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
15:57:35.433 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /fe80:0:0:0:cb13:3619:e430:c5ee%utun0
15:57:35.433 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface utun0
15:57:35.433 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface awdl0
15:57:35.433 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
15:57:35.433 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /fe80:0:0:0:18af:8aff:fece:8150%awdl0
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface awdl0
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface en1
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /fe80:0:0:0:102d:5526:23eb:a39a%en1
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /192.168.1.168
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface en1
15:57:35.434 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface lo0
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? true
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Ignoring remote address on loopback interface /fe80:0:0:0:0:0:0:1%lo0
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback address /0:0:0:0:0:0:0:1
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback address /127.0.0.1
15:57:35.435 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding loopback multicast interface lo0
15:57:35.442 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:57:35.444 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
15:57:35.480 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:57:35.485 [DEBUG] [org.gradle.internal.remote.internal.inet.TcpOutgoingConnector] Attempting to connect to [e2a9cb1d-ba63-4bc7-a92e-80d7047f417f port:55430, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]].
15:57:35.485 [DEBUG] [org.gradle.internal.remote.internal.inet.TcpOutgoingConnector] Trying to connect to address /0:0:0:0:0:0:0:1.
15:57:35.496 [DEBUG] [org.gradle.internal.remote.internal.inet.TcpOutgoingConnector] Connected to address /0:0:0:0:0:0:0:1:55430.
15:57:35.545 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Connected to daemon DaemonInfo{pid=4141, address=[e2a9cb1d-ba63-4bc7-a92e-80d7047f417f port:55430, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1501487654204, context=DefaultDaemonContext[uid=5cdc47f7-1070-4416-bb67-9332f9d99123,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home,daemonRegistryDir=/Users/aven/.gradle/daemon,pid=4141,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=CN,-Duser.language=zh,-Duser.variant]}. Dispatching request Build{id=07ab7349-26c5-488b-a050-da26c9dba9c0.1, currentDir=/opt}.
15:57:35.545 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Build
15:57:35.583 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result org.gradle.launcher.daemon.protocol.BuildStarted@77102b91 from daemon DaemonInfo{pid=4141, address=[e2a9cb1d-ba63-4bc7-a92e-80d7047f417f port:55430, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1501487654204, context=DefaultDaemonContext[uid=5cdc47f7-1070-4416-bb67-9332f9d99123,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home,daemonRegistryDir=/Users/aven/.gradle/daemon,pid=4141,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} (build should be starting).
15:57:35.576 [INFO] [org.gradle.launcher.daemon.server.exec.LogToClient] The client will now receive all logging from the daemon (pid: 4141). The daemon log file: /Users/aven/.gradle/daemon/4.0.2/daemon-4141.out.log
15:57:35.577 [INFO] [org.gradle.launcher.daemon.server.exec.LogAndCheckHealth] Starting 12th build in daemon [uptime: 48 mins 31.679 secs, performance: 97%, no major garbage collections]
15:57:35.577 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has started executing the build.
15:57:35.577 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] Executing build with daemon context: DefaultDaemonContext[uid=5cdc47f7-1070-4416-bb67-9332f9d99123,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home,daemonRegistryDir=/Users/aven/.gradle/daemon,pid=4141,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
15:57:35.580 [INFO] [org.gradle.internal.work.DefaultWorkerLeaseService] Using 4 worker leases.
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:57:35.622 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.internal.service.ServiceCreationException: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:797)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:761)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:747)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:761)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:747)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:344)
15:57:35.623 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:325)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncherFactory.doNewInstance(DefaultGradleLauncherFactory.java:150)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.DefaultGradleLauncherFactory.newInstance(DefaultGradleLauncherFactory.java:95)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:38)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:51)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:32)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:64)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:29)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:50)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:30)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
15:57:35.624 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.Swapper.swap(Swapper.java:38)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
15:57:35.625 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.internal.service.ServiceCreationException: Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:797)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:761)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:747)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:344)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:329)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$ParentServices.getService(DefaultServiceRegistry.java:1111)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.getService(DefaultServiceRegistry.java:970)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CompositeProvider.getService(DefaultServiceRegistry.java:1034)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1356)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1353)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.getServiceProvider(DefaultServiceRegistry.java:1297)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.find(DefaultServiceRegistry.java:1285)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.bind(DefaultServiceRegistry.java:722)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.prepare(DefaultServiceRegistry.java:628)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.getService(DefaultServiceRegistry.java:642)
15:57:35.626 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.getService(DefaultServiceRegistry.java:465)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.getService(DefaultServiceRegistry.java:970)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CompositeProvider.getService(DefaultServiceRegistry.java:1034)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1356)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1353)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.getServiceProvider(DefaultServiceRegistry.java:1297)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.find(DefaultServiceRegistry.java:1285)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.bind(DefaultServiceRegistry.java:722)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.prepare(DefaultServiceRegistry.java:628)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.getService(DefaultServiceRegistry.java:642)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.getService(DefaultServiceRegistry.java:465)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CachingProvider.getService(DefaultServiceRegistry.java:970)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$CompositeProvider.getService(DefaultServiceRegistry.java:1034)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1356)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext$4.apply(DefaultServiceRegistry.java:1353)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.getServiceProvider(DefaultServiceRegistry.java:1297)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$DefaultLookupContext.find(DefaultServiceRegistry.java:1285)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.getServiceProvider(DefaultServiceRegistry.java:350)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:341)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry.get(DefaultServiceRegistry.java:325)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildScopeServices.defaultScriptPluginFactory(BuildScopeServices.java:304)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildScopeServices.createScriptPluginFactory(BuildScopeServices.java:296)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:35)
15:57:35.627 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:795)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 56 more
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.UncheckedIOException: Failed to create parent directory '/opt/.gradle' when creating directory '/opt/.gradle/4.0.2/fileHashes'
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.GFileUtils.mkdirs(GFileUtils.java:317)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:54)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:30)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheFactory.doOpen(DefaultCacheFactory.java:89)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheFactory.open(DefaultCacheFactory.java:63)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.cache.internal.DefaultCacheRepository$PersistentCacheBuilder.open(DefaultCacheRepository.java:123)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.changedetection.state.CrossBuildFileHashCache.<init>(CrossBuildFileHashCache.java:41)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.scopes.BuildSessionScopeServices.createCrossBuildFileHashCache(BuildSessionScopeServices.java:216)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:35)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:795)
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 100 more
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
15:57:35.628 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 4s
15:57:35.629 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has finished executing the build.
15:57:35.724 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@4fe0480e
15:57:35.731 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 13: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
15:57:35.732 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().] from daemon DaemonInfo{pid=4141, address=[e2a9cb1d-ba63-4bc7-a92e-80d7047f417f port:55430, addresses:[/0:0:0:0:0:0:0:1, /127.0.0.1]], state=Idle, lastBusy=1501487654204, context=DefaultDaemonContext[uid=5cdc47f7-1070-4416-bb67-9332f9d99123,javaHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home,daemonRegistryDir=/Users/aven/.gradle/daemon,pid=4141,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} (build should be done).
15:57:35.732 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
15:57:35.734 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop

在最后一个 Caused by 的位置我们可以看到错误信息是:

Caused by: org.gradle.api.UncheckedIOException: Failed to create parent directory '/opt/.gradle' when creating directory '/opt/.gradle/4.0.2/fileHashes'

创建目录失败了,估计是权限的原因!

于是:

$ sudo gradle
Password:
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :help

Welcome to Gradle 4.0.2.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL in 9s
1 actionable task: 1 executed

命令执行成功了,说明真的是权限的原因。

小结

我是使用 sdk 命令安装完成 gradle 之后,遇到的问题,由于初次使用 sdk,以为是它的问题,所以又打开了一个终端窗口,使用 Homebrew 又安装了一遍,装完就好了,所以感觉这个问题非常的奇怪!开始使用命令“$ gradle --info --debug --stacktrace”查看详细原因的时候,由于粗心,也没有发现具体原因,就像Java程序出错时控制台输出长长的调用堆栈信息一样,看着就头大,所以很少会有人细心的去看,结果就错过了解决问题的最好的提示信息。

我这里是遇到的权限的原因,你可能遇到同样的错误提示,但本质的错误原因有可能并不相同,但你掌握了这样查找错误根本原因的方法,相信解决起来就比较简单了。


方法在哪里?

认准官方指定关键词“ Caused by ”!

相关阅读:

《gradle 用户指南中文版》目录

gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea的更多相关文章

  1. Mongodb之failed to create service entry worker thread

    Mongodb "failed to create service entry worker thread" 错误. 系统:CentOS release 6.8 mongod.lo ...

  2. orcle自定义类型type/create or replace type

    一.type / create or repalce type 区别联系 相同: 可用关键字create type 或者直接用type定义自定义类型, 区别: create type 变量 as ta ...

  3. InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]'

    在新建asp.net core 应用后, 添加了自定义的ApplicationDbContext 和ApplicationUser ,并添加了Identity认证后, 会出现 InvalidOpera ...

  4. No service of type Factory<LoggingManagerInternal> available in ProjectScopeService

    导入GitHub上下载的项目时报错 No service of type Factory<LoggingManagerInternal> available in ProjectScope ...

  5. Ant Problem: failed to create task or type foreach 问题

    用eclipse导出android时总是会出现有类没有导出的现象,感觉非常麻烦,就用ant些了脚本.在eclipse中运行脚本没问题.可是在命令行下运行会出现 Problem: failed to c ...

  6. Error:(2, 0) No service of type Factory<LoggingManagerInternal> available in ProjectScopeServices. <

    compile报下面的错误Error:(2, 0) No service of type Factory available in ProjectScopeServices. 点击open file ...

  7. Unable to resolve service for type 'Microsoft.AspNetCore.ResponseCompression.IResponseCompressionProvider' while attempting to activate 'Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMid

    System.InvalidOperationException HResult=0x80131509 Message=Unable to resolve service for type 'Micr ...

  8. Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'xxxxx.Controllers.xxxxController'.

    Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activa ...

  9. Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor'

    An unhandled exception occurred while processing the request. InvalidOperationException: Unable to r ...

随机推荐

  1. jQuery :gt 选择器 jQuery :lt 选择器

    选择前 3 个之后的所有 <tr> 元素: $("tr:gt(2)"); 选择前 2 个 <tr> 元素: $("tr:lt(2)");

  2. mysql-community-server安装完后不知道root密码

    修改方法: service mysqld stop mysqld_safe --skip-grant-tables & mysql -u root use mysql; update user ...

  3. 为什么Eureka Client获取服务实例这么慢

    1. Eureka Client注册延迟 Eureka Client启动后不会立即向Eureka Server注册,而是有一个延迟时间,默认为40s 2. Eureka Server更新响应缓存 Eu ...

  4. 在VMware中使用Nat方式设置静态IP

    为了在公司和家中不改变ip,所以采用vm的NAT模式来设置静态ip 1.vm采用NAT模式联网 2.编辑vm虚拟机设置 3.查看该网段的网关 可以看出网关为192.168.44.2,然后开始设置静态i ...

  5. 同一个tomcat启动多个实例

    一般在使用Tomcat时,服务器会从conf及webapps目录中读取配置文件,并将文件写入logs.temp和work目录,当然一些jar文件和class文件需要从服务器的公共目录树中予以加载.因此 ...

  6. 20144303 《Java程序设计》第一次实验实验报告

    20144303 <Java程序设计>第一次实验实验报告 北京电子科技学院(besti)实验报告 课程:java程序设计 班级:1453 指导教师:娄嘉鹏 实验日期:2016.04.08 ...

  7. linux input输入子系统分析《四》:input子系统整体流程全面分析

    1      input输入子系统整体流程 本节分析input子系统在内核中的实现,包括输入子系统(Input Core),事件处理层(Event Handler)和设备驱动层.由于上节代码讲解了设备 ...

  8. Http中Get和Post的区别(转载)

    在B/S应用程序中,前台与后台的数据交互,都是通过HTML中Form表单完成的.Form提供了两种数据传输的方式——get和post.虽然它们都是数据的提交方式,但是在实际传输时确有很大的不同,并且可 ...

  9. cogs 341:[NOI2005] 聪聪与可可

    ★★   输入文件:cchkk.in   输出文件:cchkk.out   简单对比 时间限制:1 s   内存限制:256 MB [问题描述] 在一个魔法森林里,住着一只聪明的小猫聪聪和一只可爱的小 ...

  10. 混合开发的大趋势之一React Native手势行为那些事

    转载请注明出处:王亟亟的大牛之路 最近项目部分模块重构,事情有点多,学习进度有所延缓,外加一直在吸毒(wow你懂的),导致好多天没发问了,其实这部分知识月头就想写了,一直没补. 话不多说先安利:htt ...