Reputation: 111
I am new in gradle and when I try to simple check gradle built in tasks, I get Build Failed error.
Can anybody explain what is wrong?
I only run 'gradle tasks' on cmd and get next error:
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService().
> Timeout waiting to lock checksums cache (M:\.gradle\checksums). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 14372
Owner Operation: unknown
Our operation:
Lock file: M:\.gradle\checksums\checksums.lock
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with
--scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 1s
Upvotes: 11
Views: 15505
Reputation: 1
I was facing the same issue, and I tried using ./gradlew --stop
, but that didn’t work for me.
What eventually fixed it was removing the .gradle
folder in my project directory (or the global .gradle
folder). After deleting it, the lock error was resolved, and I could run any gradle command without any issues.
Upvotes: 0
Reputation: 1
I got this problem while building via terminal in WSL without me realizing that the Windows Intellij window I had opened was also building (typically Intellij will build by default when opening projects, or when switching branches, etc.). The building does take long and I did not notice. If that is your case, simply wait until the build is done or cancel it.
Upvotes: 0
Reputation: 422
This work for me:
Upvotes: 0
Reputation: 111
For Flutter users
I faced this problem on Mac OS Monterey (M1 processor)
I solved it in the following way
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'. //---this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
cd android
despues
./gradlew --stop
4.Run flutter clean and flutter pub get
flutter clean
flutter pub get
flutter run
Upvotes: 1
Reputation: 7572
./gradlew --stop
as the error happens when gradle didn't close cleanly. Such as in: Cannot lock checksums cache (/Users/.../StudioProjects/android/.gradle/7.4.2/checksums) as it has already been locked by this process.
Upvotes: 19
Reputation: 2376
FWIW, I forgot to stop the server in IntelliJ and once I did the problem went away.
Upvotes: 1
Reputation: 1015
This was a permissions issue for me. I tried running a project on my Mac from my mounted Google Drive directory and got this error.
Moving the project to Documents worked.
Upvotes: 5