I try to change minSdkVersion
in build.gradle
(Module: app) in Android Studio
and get next error:
Error:Timeout waiting to lock buildscript class cache for build file 'E:\pathtoproject\app\build.gradle' (C:\Users\Administrator\.gradle\caches\2.2.1\scripts\build_f00bwdji3qxl7urq5chsbakgv\ProjectScript\buildscript). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 4592
Owner Operation: unknown
Our operation: Initialize cache
Lock file: C:\Users\Administrator\.gradle\caches\2.2.1\scripts\build_f00bwdji3qxl7urq5chsbakgv\ProjectScript\buildscript\cache.properties.lock
What is it error? How to change minSdkVersion
?
This sounds like it's related to https://issues.gradle.org/browse/GRADLE-2795 .
The easiest way to solve this will be to delete everything under C:\\Users\\Administrator\\.gradle\\caches
. There is a cache.properties.lock
that is holding a global lock which is preventing you from running your script.
For Mac OSX the folder is located in ~/.gradle/caches
. The Android Studio should show the proper path to the file which is causing the lock anyway.
The lock file is there because some other gradle process (usually the daemon) is using the cache. You could stop all gradle processes to release the lock
gradle --stop
https://docs.gradle.org/current/userguide/gradle_daemon.html#sec:stopping_an_existing_daemon
1.Check whether multiple instance of java.exe running then find out why they are running in my case i have opened command prompt it need java instance. open task manager and end task of cmd.exe If you don't want it to further happen remove path from environment variables and use embedded android studio JDK.
2.Delete lock file in /.gradle/cache goto task manager and close all instance of java.exe In android studio click on file invalidate caches/restart
关闭android studio并删除缓存中的任何内容
for me, it solved the problem by killing the PID
This worked for me.
ps -ef | grep gradle
rm C:\\Users\\Administrator\\.gradle\\caches\\2.2.1\\scripts\\build_f00bwdji3qxl7urq5chsbakgv\\ProjectScript\\buildscript\\cache.properties.lock
Thanks,
What worked for me:
projectPath=[yourProjectPath]
find $projectPath/.gradle -name '*.lock' -delete
You can also remove them one by one:
gradleVersion=[yourProjectGradleVersion]
projectPath=[yourProjectPath]
rm -f $projectPath/.gradle/$gradleVersion/taskHistory/taskHistory.lock $projectPath/.gradle/$gradleVersion/fileHashes/fileHashes.lock $projectPath/.gradle/$gradleVersion/fileContent/fileContent.lock $projectPath/.gradle/$gradleVersion/javaCompile/javaCompile.lock $projectPath/.gradle/buildOutputCleanup/buildOutputCleanup.lock
从 / 中删除 .gradle 文件夹并从项目中重新同步 gradle。
Your build.gradle file likely contains multiple statements of minSdkVersion
. Possibly in defaultConfig{}
block and productFlavors{}
block. Make sure you are only declaring minSdkVersion once in the build file.
Sometimes it was notable to delete filehash.lock file and it will throw an error unable to delete file. So do the following steps
For Windows machine:
Open Task Manager(Ctrl-Alt-Delete and check Process)
-> If you run two instance of android studio, Close One (End Task)
-> Then close OpenJDK Platform Binary
-> Gradle sync now on AndroidStudio and it will work now
For me the only thing that worked was deleting these things inside android folder:
Posting this for myself 2 weeks from now
Issue: If you open two Android Studios, and two of them are using Camera Services to capture image then we you face this issue.
Solution: Close One Android Studio.
For A novice like me, who encountered the situation for the first time and was not able to delete the .lock file or the .gradle folder,
In windows 10 or others, restart the pc using safe mode,(windows key + R ---> msconfig ----> select boot, boot in safe mode----> restart) then delete the files, (this should delete the files and folder)
then in normal mode, restart android studio and sync gradle to download the appropriate version (hopefully the project should work now)
"Lock file: C:\Users\Administrator\.gradle\caches\2.2.1\scripts\build_f00bwdji3qxl7urq5chsbakgv\ProjectScript\buildscript\cache.properties.lock"
You should delete the file in this extension. Then you will see that the problem is fixed. I lived the same problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.