【问题标题】:Locking files on OSX are preventing from Gradle sync on android studio, the files are getting locked repeatedly even after deleting themOSX 上的锁定文件阻止了 android studio 上的 Gradle 同步,即使在删除文件后,这些文件也会被反复锁定
【发布时间】:2020-02-02 01:41:10
【问题描述】:

我正在创建一个新的 Android 项目,详细信息如下:-

操作系统:MacBook Pro(13 英寸,2012 年中)和 mc OS mojave。版本 10.14.6, Android Studio 3.5 版

在尝试同步项目时,很少有文件被锁定并且同步失败。即使在删除它们并杀死 gradle 恶魔并再次启动同步之后,文件也会被锁定并且同步失败。

以下是错误的详细信息:-

' 错误:超时等待锁定构建输出清理缓存 (/Volumes/MYNEWVOLUME/study_material/android/ReadText/.gradle/buildOutputCleanup)。它是 当前由另一个 Gradle 实例使用。 所有者 PID:未知 我们的PID:8524 所有者操作:未知 我们的操作: 锁定文件: /Volumes/MYNEWVOLUME/study_material/android/ReadText/.gradle/buildOutputCleanup/buildOutputCleanup.lock

'

我发现当我开始同步时,两个 gradle 恶魔线程实例开始了。如果我尝试杀死其中任何一个,则同步失败。如果我让它运行,那么其中一个线程获取锁而其他线程无法获取锁,因此同步失败。

以下是 gradle 详细信息:-

    '
apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.readtext"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Gradle build details are


        '

         // Top-level build file where you can add configuration options common to all sub- 
         projects/modules.

         buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects  {


    repositories {
        google()

        jcenter ()


    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

    标签: android macos android-gradle-plugin


    【解决方案1】:

    我设法通过更改我的 android 项目的位置来解决该错误。在 android studio 建议的默认目录中创建项目,项目运行和构建正常,没有任何错误。就我而言,我最初是在一个不同的目录中创建,如上所示 /Volumes/MYNEWVOLUME/study_material/android/ReadText 。但是在/user/XXXX/AndroidStudioProjects/ReadText的默认项目目录下新建一个项目后再次出现。它开始完美运行,没有任何锁。

    【讨论】:

      猜你喜欢
      • 2011-06-28
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 2023-04-10
      • 2023-04-03
      相关资源
      最近更新 更多