java - 安卓工作室 : Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices. createGeneralCompileCaches()

标签 java android android-studio

我想寻求一些关于 Android Studio 的帮助。这是我第一次处理 Android 应用程序开发,我也没有太多的开发经验。我对这个环境还是陌生的。尽管如此,我还是觉得这项 Activity 很有趣,它为我提供了一个可以消磨时间的安全空间。

我的这个问题与代码无关,而是与IDE本身有关,这三天一直困扰着我。我已经查找了所有可能与我相似的问题,但没有一个答案对我有帮助。

我做了一个“Hello World”项目(我还没有做任何事情),但是每次运行它,我总是遇到这个问题:

Task :app:preDebugBuild UP-TO-DATE
Task :app:compileDebugAidl NO-SOURCE
Task :app:generateDebugBuildConfig UP-TO-DATE
Task :app:compileDebugRenderscript NO-SOURCE
Task :app:javaPreCompileDebug UP-TO-DATE
Task :app:generateDebugResValues UP-TO-DATE
Task :app:generateDebugResources UP-TO-DATE
Task :app:mergeDebugResources UP-TO-DATE
Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
Task :app:extractDeepLinksDebug UP-TO-DATE
Task :app:processDebugManifest UP-TO-DATE
Task :app:processDebugResources UP-TO-DATE
Task :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'.<129 internal calls>
Caused by: org.gradle.internal.service.ServiceCreationException: Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().<78 internal calls>
...126 more
Caused by: java.lang.IllegalStateException: Unexpected lock protocol found in lock file. Expected 3, found 0.<20 internal calls>
...203 more

* Get more help at https://help.gradle.org

BUILD FAILED in 25s
9 actionable tasks: 1 executed, 8 up-to-date

最佳答案

欢迎使用 Android! Android Studio 的第一条规则是,如果事情开始出错,请执行 Build > Clean。如果这没有帮助,File > Invalidate Caches/Restart。这有点像 Spring 大扫除

如果那行不通(也可能行不通,我想我以前遇到过,锁定文件的问题),您可以尝试一些方法,不能保证它们会起作用,但是嘿:

  • 运行执行 Gradle 任务(按 ctrl+shift+a 并开始输入)并执行 gradle --stop,尝试重建
  • 找到 .gradle 数据文件夹(在 Windows 上是 C:\Users\You\.gradle,进入 daemon 并找到您正在使用的 Gradle 版本(检查项目中的 gradle.wrapper.properties 文件)。删除 registry.bin.lock 文件
  • 如果这不起作用,可能会删除 .gradle\caches 文件夹,因为您的错误提到编译缓存 - 东西将不得不重新下载

我忘记了上次我必须做些什么来修复它。 There's a thread here但很多人都在尝试不同的东西。通常你不会遇到这些问题,所以你很不走运,但有时这会很痛苦。希望你能成功!

关于java - 安卓工作室 : Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices. createGeneralCompileCaches(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63513860/

相关文章:

java - LD_DEBUG 和 java

android - 工具栏菜单项间距问题

windows - 使用 genymotion 和 virtualBox 启动虚拟设备的问题

android - 奇怪的 NullPointerException WebSocketHandshake.verifyServerHandshakeHeaders 与谷歌包

java - TensorFlow Lite Android 应用程序因空对象引用而崩溃并出现 NullPointerException 'void android.widget.TextView.setText(java.lang.CharSequence)'

java - 关于应用程序日志级别的建议

android - 无效链接不调用 WebView shouldOverrideUrlLoading()

安卓工作室 : How to add end/closing tag automatically in layout xml file

java - Spring Bean 可以在不同地方使用还是在一个地方使用

android - 使用两行文本创建一个自定义按钮,每行具有不同的字体