Emin Kazımov
Emin Kazımov

Reputation: 111

Could not create service of type ChecksumService using BuildSessionScopeServices.createChecksumService()

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

Answers (8)

endlessz
endlessz

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

Semborg O.
Semborg O.

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

devblock
devblock

Reputation: 422

This work for me:

  1. Close my IDE
  2. Go to my project directory
  3. Search and delete all .lock files
  4. Open the IDE, and try again

Upvotes: 0

anDres
anDres

Reputation: 111

For Flutter users

I faced this problem on Mac OS Monterey (M1 processor)

I solved it in the following way

  1. Browse android/buil.gradle add or update gradle version to 7.1.2
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'. //---this
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
  1. Update distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to 7.4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
  1. Navigate in the terminal to the android folder and run
cd android

despues

./gradlew --stop

4.Run flutter clean and flutter pub get

flutter clean
flutter pub get
  1. Then run flutter run
flutter run

Upvotes: 1

Gabor
Gabor

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

Craig
Craig

Reputation: 2376

FWIW, I forgot to stop the server in IntelliJ and once I did the problem went away.

Upvotes: 1

Randy
Randy

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

Silas Ogar
Silas Ogar

Reputation: 97

Just restart your machine. it's a cache related error

Upvotes: -2

Related Questions