android - OSX 上的锁定文件阻止了 android studio 上的 Gradle 同步,即使在删除文件后,这些文件也被反复锁定
问题描述
我正在创建一个新的 Android 项目,以下是详细信息:-
操作系统:MacBook Pro(13 英寸,2012 年中)和 mc OS mojave。版本 10.14.6,Android 工作室版本 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项目的位置来解决错误。在 android studio 建议的默认目录中创建项目,项目运行和构建正常,没有任何错误。就我而言,我最初是在一个不同的目录中创建,如上所示 /Volumes/MYNEWVOLUME/study_material/android/ReadText 。但是在/user/XXXX/AndroidStudioProjects/ReadText的默认项目目录下新建一个项目后再次出现。它开始完美运行,没有任何锁。
推荐阅读
- excel - 将列的文本转换为多列的正确方法是什么?
- docker - 如何在本地部署中删除 Kubernetes 资源?
- reactjs - Immer 和 Redux Starter Kit 的 findIndex 问题
- android - 安卓。应用程序进入后台后一分钟内自动关闭第二个活动
- ios - CLLocation Manager 有时会给出不正确的位置
- java - 为什么 Spring Data REST 搜索返回的页面没有页面信息?
- php - 如果只有图像,我的页面就会显示
- c# - unity 对象初始化同步
- r - 如何在不预先知道预测变量数量的情况下在 R 中进行多因素回归(一般线性模型)?
- ios - Universal url scheme on iOS