Gradle sync failed: Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2h

Posted

技术标签:

【中文标题】Gradle sync failed: Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2hfc9tvdzsey2shpvt2yk7sb 它当前正在被 a【英文标题】:Gradle sync failed: Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2hfc9tvdzsey2shpvt2yk7sb It is currently in use by a 【发布时间】:2017-10-21 02:55:43 【问题描述】:

本来想把gradle移动到新目录:/ Volumes / FLASHMEMORY / android / Gradle

但是由于昨天我从原系统的原目录中删除了gradle文件夹,并在Android Studio中重新指定了目录,所以无论是新项目还是原项目,所有的项目都无法编译。

我总是遇到如下相同的错误信息:

Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2hfc9tvdzsey2shpvt2yk7sb (/Volumes/FLASHMEMORY/Android/Gradle/caches/3.3/scripts-remapped/asLocalRepo_2l9w7fvtmyueda6rnni9t3t84/a2hfc9tvdzsey2shpvt2yk7sb/cp_init1efd45104ffa2d33563b85b9edda76e3) It is currently in use by another Gradle instance..
Owner PID: unknown
Our PID: 3461
Owner Operation: unknown
Our operation:
Lock file: /Volumes/FLASHMEMORY/Android/Gradle/caches/3.3/scripts-remapped/asLocalRepo_2l9w7fvtmyueda6rnni9t3t84/a2hfc9tvdzsey2shpvt2yk7sb/cp_init1efd45104ffa2d33563b85b9edda76e5/tow_init1efd45104ffa2d33563b85b9edda76e3.lock
Consult IDE log for more details (Help | Show Log)

我的 Android Studio 设置:

Project-level settings: Use default gradle wrapper (recommended)
Global Gradle settings-> Service directory path: / Volumes / FLASHMEMORY / Android / Gradle

项目根目录下的build.gradle文件:

buildscript 
    repositories 
        jcenter()
    
    dependencies 
        classpath 'com.android.tools.build:gradle:2.3.2'
    

allprojects 
    repositories 
        jcenter()
    

task clean(type: Delete) 
    delete rootProject.buildDir

模块目录下的build.gradle文件:

apply plugin: 'com.android.application'
android 
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig 
        applicationId "com.cnblogs.guqiangjs.myapplication"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    
    buildTypes 
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    

dependencies 
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
        exclude group: 'com.android.support', module: 'support-annotations'
    )
    compile 'com.android.support:appcompat-v7:25.3.1'
    testCompile 'junit:junit:4.12'

Gradle-wrapper.properties 文件内容:

DistributionBase = GRADLE_USER_HOME
DistributionPath = wrapper / dists
ZipStoreBase = GRADLE_USER_HOME
ZipStorePath = wrapper / dists
DistributionUrl = https \: //services.gradle.org/distributions/gradle-3.3-all.zip

我试过了:

删除锁定的文件。

清空整个 / Volumes / FLASHMEMORY / Android / Gradle 文件夹。

重新安装 Android Stuido。

但以上尝试都以失败告终……

也请帮忙!谢谢!

【问题讨论】:

【参考方案1】:

哎呀!今天尝试把Gradle目录改回电脑盘,问题解决了!

我只修改了一个内容:

Android Stuido -> Global Gradle settings -> Service directory path: /Users/MyUserName/Documents/Gradle

【讨论】:

以上是关于Gradle sync failed: Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2h的主要内容,如果未能解决你的问题,请参考以下文章

解决Gradle sync failed: Gradle Sync Issues问题(Android开发)

Gradle project sync failed

Gradle sync failed: Gradle sync failed: Timeout waiting to lock cp_init remapped class cache for a2h

Gradle Sync Failed:Setup Project Failed:Null

android studio 更新 Gradle错误解决方法(Gradle sync failed)

Gradle工程错误:Gradle sync failed: Java home is different