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

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

./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.

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.

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

For Flutter users
I faced this problem on Mac OS Monterey (M1 processor)
I solved it in the following way
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"
}
Update distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to 7.4
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
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
Then run flutter run
flutter run

This work for me:
Close my IDE
Go to my project directory
Search and delete all .lock files
Open the IDE, and try again

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

Related

Intellij + Gradle Could not create service of type FileHasher using BuildSessionServices.createFileHasher()

I have imported a new Gradle project i have to start working on, my IDE is Intellij updated to the latest version 2021.2.4
As soon as the build starts i get:
FAILURE: Build failed with an exception.
* What went wrong:
Gradle could not start your build.
> Could not create service of type FileHasher using BuildSessionServices.createFileHasher().
> Unexpected lock protocol found in lock file. Expected 3, found 0.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I have tried every single proposed solution in this thread (90% of them propose to delete the caches from the .gradle or its entire folder), but nothing worked.
Does anyone have a different solution?
My windows 10 FS yesterday night froze and after the restart this issue showed up.

Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory

For some unknown reason, whenever I run gradle clean build after I start my notebook it works as expected. When I try for the second time, I always get
Unable to delete directory 'C:\_d\mycompany\WSs\demo\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com\mybank
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test
- C:\_d\mycompany\WSs\demo\build\classes\kotlin
- C:\_d\mycompany\WSs\demo\build\classes
- C:\_d\mycompany\WSs\demo\build\generated\source\kapt
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\main
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\test
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin
- C:\_d\mycompany\WSs\demo\build\generated\source
- C:\_d\mycompany\WSs\demo\build\generated
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\inputs
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm\kotlin
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm
- and more ...
New files were found. This might happen because a process is still writing to the target directory.
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin
I found someone failing quite similar problem but using Android Studio/Ubuntu (I am using IntelliJ Community/Windows 10): other question
I tried carefully all recommendations and none of them fixed my issue. I only get it working back if I restart my Windows and just work one time.
Some of the recommendations are:
1 - Close the studio and go to the path the issue is located at and delete the folder there.
I tried close IntelliJ and I can't delete the folder straight
2 - File > Settings > Build, Execution, Deployment > Instant Run > Uncheck this Check box (Enable Instant Run to hot swap code)
There is no such optional in my IntelliJ
IntelliJ IDEA 2020.2.3 (Community Edition)
Build #IC-202.7660.26, built on October 6, 2020
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1963M
Cores: 8
Non-Bundled Plugins: Lombook Plugin, org.jetbrains.kotlin
3 - gradlew clean
Same issue
4 - right-click on the directory, click properties on the context menu that will appear, then uncheck the "Read Only" attribute. After that, click the "Apply" to apply changes.
I am administrator but I couldn't change such folder attribute.
5 - Running android studio as administrator in windows worked for me.
Same issue
Here are my build.gradle
plugins {
id "org.jetbrains.kotlin.jvm" version "1.4.10"
id "org.jetbrains.kotlin.kapt" version "1.4.10"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.10"
id "com.github.johnrengelman.shadow" version "6.1.0"
id "io.micronaut.application" version '1.0.5'
id "com.gorylenko.gradle-git-properties" version "2.2.2"
}
version "0.1"
group "com.mybank"
repositories {
mavenCentral()
jcenter()
}
micronaut {
runtime "netty"
testRuntime "junit5"
processing {
incremental true
annotations "com.mybank.*"
}
}
dependencies {
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-management")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
runtimeOnly("com.h2database:h2")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
mainClassName = "com.mybank.ApplicationKt"
java {
sourceCompatibility = JavaVersion.toVersion('11')
}
compileKotlin {
kotlinOptions {
jvmTarget = '11'
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '11'
}
}
gradle.properties
micronautVersion=2.1.3
kotlinVersion=1.4.10
and the build folder seen in IntelliJ
*** edited
I didn't find how fix it. Now is happening with a project I have just cloned from micronaut
And I can't delete build folder although I am Windows administrator
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle clean build
> Task :clean FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clean'.
> java.io.IOException: Unable to delete directory 'C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in
the target directory.
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 13s
1 actionable task: 1 executed
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle stop
FAILURE: Build failed with an exception.
* What went wrong:
Task 'stop' not found in root project 'hello-world-kotlin'.
* Try:
Run gradle tasks to get a list of available tasks. 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin>
The problem is that you have multiple Gradle processes that are still holding locks to your files.
You can try running gradle --stop when this happens to stop any daemons that are running in the backgorund (this usually helps).
You can also check the state of your daemons by running gradle --status. For me this outputs:
No Gradle daemons are running.
Only Daemons for the current Gradle version are displayed.
See https://docs.gradle.org/6.5/userguide/gradle_daemon.html#sec:status
If you see something there it might be a problem.
Using --no-daemon and --no-parallel might help, but they would just hide the underlying problem.
In my case when this happened I realized that I had processes running in the background because of tests never finishing. Check all your threading and/or coroutine usage for unclosed / unfinished processes.
One other case when this happened to me is when I was using ProcessBuilder to start another Java process and it didn't exit.
Just rename the " build " folder.
In my case, I experienced this error after I ran a Gradle command as the root user in Linux.
After switching back to a regular user, Gradle gave me the above error. When I tried to remove the build directory using rm -rf build/, I received a "Permission denied" error. You can solve this problem by removing the build directory as the root user.
For me the files where under a different user and the group and the permissions were not sufficient to write to the files of the directory in question.
Try checking who the user of the project files are with ls -al
If the project and the sub directories and files are under a different user. You can run sudo chown -R [new_owner] [project_folder_name] The flag -R here recursively changes owner for the sub files and sub dirs.
You can also add additional permissions to the group (if the user belongs to the group) or even change the group (if the user does not belong to the group). The basic idea is giving the user enough permission (rwx) to use files.
In Windows 10 Kill all Java TM instances by running this command on command prompt :
TASKKILL /F /IM java.exe
Or you delete your app installed on your phone and reinstall it again.This solved my problem
As I have faced similar kinds of errors during the flutter app development, I have figured out which process is blocking the running app. So I have just ended Open JDK from the Process list and then retried running the app without debug mode and it's working. The thing I learned here is that we have multiple development environments running in the background so we have to determine which process is blocking others.
Delete build folder in this path : your project\app . Then rebuild project.
If you are running windows 10, Go to task manager and end the following task
.......................
Java Platform SE binary
There might be more than one above mentioned task just end all of them and rebuild works
I went to my file system and deleted the file manually. Restarted my android

Minecraft Forge Gradle with VSCode

I am trying to create a Minecraft Mod using VSCode as this is my main editor for school, but when I try to run the command gradlew genVSCodeRun I get the follwoing output that says successful, but also "Could not resolve: net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20190719-1.14.3". When I then run gradlew build, the following it output:
Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
Could not find net.minecraftforge:forge:1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.
Searched in the following locations:
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- file:/C:/Users/eabla/.gradle/caches/forge_gradle/bundeled_repo/net/minecraftforge/forge/1.15.2-31.1.0_mapped_snapshot_20200119-1.15/forge-1.15.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://libraries.minecraft.net/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.pom
- https://repo.maven.apache.org/maven2/net/minecraftforge/forge/1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3/forge-1.14.3.2-31.1.0_mapped_snapshot_20200119-1.14.3.jar
Required by:
project :
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 40s
1 actionable task: 1 executed
Any idea what this could be? I have done a fresh install of java JDK and JRE as well as a fresh install of the Forge MDK.
Your Forge Library is missing. Run the command gradlew eclipse after navigating into your project directory. It may take some time but it will surely fix it. :D
Make sure you have the JDK (java development kit https://www.oracle.com/java/technologies/javase-jdk8-downloads.html) installed not just the JRE

When i am trying to run my flutter app it getting an Error running gradle

i am getting an error when i trying to run the app. please help. The error in cmd is below -
Error running Gradle:
ProcessException: Process "C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\app\build.gradle' line: 14
What went wrong:
A problem occurred evaluating project ':app'.
ASCII
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 14s
Command: C:\Flutter projects\FlatApp-Firebase-Flutter-master\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
line nine in app-build-gradle is below-
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
There could be many reasons for such a error. I had a similar error. I would suggest you to open your project in android studio and check your gradel versions. I see by the name of you app that you are using firebase. Some of those plugins use Androidx. So migrating your project to Androidx might help. Here's how to migrate your project to Androidx.
Hope it helps!
I had the same issue this may because of the incompatibility of Gradle versions.
I opened the android part in Android Studio and updated Gradle as recommended by Android Studio with Alt+Enter and it solved my problem.
I can elaborate more if you can post more details about it e.g your app/gradle file.

Android studio build error

Tried to create my first project in android studio, using one of the examples im trying to run the application, but gradle gives me this build error (didnt change one line of code - just trying to run the Empty activity):
Gradle: FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':Passivelocation:packageDebug'.
org.bouncycastle.asn1.ASN1Integer.(J)V
* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Ive tried adding info and debug while running the command on with the cli but i cant make much of the output it gives me.
Any suggestions?
I faced the same failure and the problem was with my jdk/jre because some time ago I added the Bouncy Castle Crypto APIs functionality by adding the jar to my jdk/jre path.
I tried a gradle build with a "clean" jdk/jre and problem was solved

Resources