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

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.

Related

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

IntelliJ IDEA (2020.2): Gradle: Lock file: repository/caches/journal-1/journal-1.lock

I am working with Intellij Idea (CE)
2020.2.3
And using Gradle 6.7
Path Variables
Where in the OS exists configured, the following about Path Variables in the bash profile:
GRADLE_HOME = /Users/username/.../gradle/6.7
GRADLE_USER_HOME = /Volumes/FP27072011/gradle/repository
How you can see, customized locations
The /Users/username/.gradle directory is empty.
About Intellij Idea, its configuration for Gradle is as follows:
Same paths as the bash profile.
Note
The following figures that represents the interaction with the IDE, are based on:
/Users/username/.gradle directory empty
/Volumes/FP27072011/gradle/repository directory empty
Working with spring-framework project based on Gradle
It to have a quick discard something around there.
Ok, startup process:
Starts to Sync
A Gradle's daemon is started
After of some seconds fails with:
The error message is:
Gradle could not start your build.
> Could not create service of type FileAccessTimeJournal using GradleUserHomeScopeServices.createFileAccessTimeJournal().
> Timeout waiting to lock journal cache (/Volumes/FP27072011/gradle/repository/caches/journal-1). It is currently in use by another Gradle instance.
Owner PID: unknown
Our PID: 713
Owner Operation: unknown
Our operation:
Lock file: /Volumes/FP27072011/gradle/repository/caches/journal-1/journal-1.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.
The repository directory shows the following
The /Users/username/.gradle directory shows
Observation: Until this point observe in the two previous Figures that the daemon/6.7 path/directory appears twice in the repository and .gradle directories respectively
Note: When the IDE is closed, just in that moment, in the /Users/username/.gradle directory appears this new file (registry.bin.lock) as follows:
I got this behavior even if I delete the idea-directory-installation/.gradle directory (not /Users/username/.gradle directory) and even with Invalidating Caches/Restart
What is missing, what to do?

Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ on generate APK

My project is run on AVD properly. but when i try to generate signed APK, gradle get this error:
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
> Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
* 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
I've used this command many times: gson.fromJson. but i can't find error source. (which file and which line).
So how do I find the source of the error
I got this problem in Android Studio 4.0 when I did a Gradle sync. I fixed it by doing the following:
Open top-level build.gradle and change the gradle classpath to:
classpath 'com.android.tools.build:gradle:4.0.0'
Open gradle\wrapper\gradle-wrapper.properties and change the distribution URL to:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Copy in .idea\jarRepositories.xml from a new project
No idea how or why, but it worked for me
I got this error in Android Studio 4.0 when I did a Gradle sync after switching branches. I fixed it by doing this:
Build -> Clean Project
Sync Project with Gradle files
I had the same problem when I tried to build a "signed release APK". I was using Android Studio Beta 4.0.
To fix the problem, I've upgraded to Beta 4.0 v4 and it resolved the problem.
i changed the place where my APKs generated inside and it's working fine now

Connecting to the Gradle build

I am working with Liferay 7.2. I am using Liferay Developer Studio and Gradle as a build tool.
While creating a new module project after creating of 1-2 new, getting error message in IDE's workspace .log file and new module project is not creating.
!MESSAGE Synchronize project liferay-workspace failed due to an error connecting to the Gradle build. !STACK 0 org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.10.2-bin.zip'.
In C:\Users\nirav.prajapati.gradle\daemon\4.10.2\daemon-11084.out file following error shows.
Problem in daemon expiration check java.lang.OutOfMemoryError: GC
overhead limit exceeded FAILURE: Build failed with an exception.
* What went wrong: GC overhead limit exceeded
* 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
Problem in daemon expiration check java.lang.OutOfMemoryError: Java
heap space Failed to execute
org.gradle.launcher.daemon.server.Daemon$DaemonExpirationPeriodicCheck#7f47f3a7.
java.lang.OutOfMemoryError: Java heap space FAILURE: Build failed with
an exception.
* What went wrong: Failed to notify build listener. Java heap space
I have increased JVM Heap size by double click on IDE's Server.
Even newly created project is not showing into Gradle Task. In Project Explorer it's showing like incomplete project means folder structure are different then exists. Moreover, .projects and .settings file is also not creating in that.
Multiple time I have make fresh configuration like, remove Liferay developer studio, workspace and .gradle folder from C:\User\
After getting this error, I have restarted system and start again liferay developer studio, but Synchronize Gradle Project with Workspace progress is taking more than 45 min. to complete the process.
Please help me to solve it.
Please these properties in gradle.properties file.
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=500m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

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