Gradle Failed to create a service of type InitScriptHandler using BuildScopeServices.createInitScriptHandler ()

I used the gradation build command in the Centos 7 terminal, and I got the result:

FAILURE: Build failed with an exception. * What went wrong: Could not create service of type InitScriptHandler using BuildScopeServices.createInitScriptHandler(). * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
+38
gradle
source share
17 answers

Try setting the GRADLE_USER_HOME variable to a folder that you have valid access to. Then this error will disappear.

For example: I ran into the same problem today when I was doing gradle clean on a new slave machine.

My version of Gradle was 2.3.

With --stacktrace, I found out that he was trying to create a .gradle folder to store Gradle cache data (while I was calling Gradle to run a clean task on the slave), and he was trying to create this folder in / some / location / where / gradle / exists OR some / path / location / xxx / yyy, where the user who ran Gradle on the slave computer did not have real write access (create folder / files).

that is, the user I used to connect from a Jenkins computer to a subordinate did not have write permission to touch / mkdir in the default folder (where Gradle thought, okay, I have to create a .gradle folder here).

To fix this, I added the aforementioned GRADLE_USER_HOME variable in the slave variable section of GRADLE_USER_HOME . Now that I have valid access in my home directory, I was fine.

enter image description here

Environment:

 GRADLE_USER_HOME=~/gradle_2_3_cache/.gradle 

solved a problem.

You can also set it to ~ / .gradle. But I put it under the user folder in my ~ home directory (gradle_2_3_cache). This will help me if I have another slave running on the same slave computer, but with a different version of Gradle for version 2.5, etc., And if I need the .gradle cache for version 2.3 and 2.5 / x in separate folders.

+35
source share

For me, killing the Gradle daemon ( gradle --stop ) really helped and the gradle --stop problem.

+18
source share

The problem was solved by simply using "sudo" and providing access to the gradient to create a folder and write a cache. use:

 sudo ./gradlew 
+10
source share

I have the same problem. For me, this worked after I excluded the .gradle folder if you cannot delete the rename attempt.

+7
source share

If you use the gradlew wrapper, in the root directory of make.gradle_new

 mkdir .gradle_new chmod -R 777 .gradle_new 

and run gradlew with arguments:

 --project-cache-dir .gradle_new 
+7
source share

If you just upgraded your JDK version and created your Gradle project, you can double check the wrapper version that supports your new JDK. If not, consider removing the shell-related files from the project ( gradlew , gradlew.bat and gradle/wrapper/* ) and re- gradle/wrapper/* them using the Gradle CLI, for example:

 gradle wrapper --gradle-version <new-version-number> 

e.g. gradle wrapper --gradle-version 4.10.2

This, of course, assumes your Gradle installation has been updated. If not, first you want to update this.

+5
source share

Restarting the machine solved the problem.

+2
source share

I got the same error, got rid of it using the correct version of Java / JDK. I tried to build a Java 8 project using the Java 11 JDK. Check which version of the Java JDK you are using.

For parallel development of projects with different versions of Java, now I use jEnv to manage different versions of the JDK: http://www.jenv.be/

+1
source share

This is a matter of resolution. make gradle wrapper --stacktrace you should see something like this Failed to create parent directory '/ home / cloud_user / my-project / gradle' when creating directory '/ home / cloud_user / my-project / gradle / wrapper'

cloud_user user does not have access to the directory that makes cloud_user the owner of the sudo chown -R cloud_user:cloud_user/home/cloud_user/my-project/

+1
source share

If you use the Invoke Gradle script build step, click Advanced to open advanced options. Find "Force GRADLE_USER_HOME to use workspace" and check it.

Invoke Gradle script screenshot

+1
source share

In future. I had the same problem, the problem was that the antivirus blocked the OpenJdk binary platform and java.exe , which prevented Android studio from changing files

0
source share

I came across this exception when trying to create a project that was mounted as a read-only file system in a virtual machine. The project set its own gradient cache, so changing GRADLE_USER_HOME did not work. I had to change the file system for reading / writing.

0
source share

You just need to run it under superuser (sudo ....), it works for me

0
source share

For me, this was due to Java versions. I have Java 10 installed and as Java by default on my system. Setting JAVA_HOME pointing to Java 8 was sufficient to build the project (graphql-spring-boot).

0
source share

My computer reboot worked

0
source share

If you run Docker-in-Docker and mount the project directory from the docker host directly into the docker container:

-v ${PWD}:/path_to_project -w /path_to_project

the owners are different, and the docker container user (gradle or root) cannot override / delete ./buildSrc/build or ./build/

One fix is ​​to copy the source codes inside the container to a temporary directory and create it there.

Something like this (first mounted in project , but then copied to project-copy to β€œseparate” the real host system files and run the build in copy):

 docker run -v "${PWD}":/home/gradle/project -w /home/gradle/project-copy \ --rm \ --entrypoint sh \ gradle:5.5.1-jdk11 \ -- -c "cp -r -T /home/gradle/project ./ && ./gradlew build" 
0
source share

In my case, I had bad credentials for the private Maven repository. JIdea does not show an internal exception, but running gradle build immediately identifies the problem.

0
source share

All Articles