11

I try to build my gradle project and I get the following error:

1:36 PM Gradle sync failed: Unable to make field private static final java.util.Map java.lang.ProcessEnvironment.theCaseInsensitiveEnvironment accessible: module java.base does not "opens java.lang" to unnamed module @7d417077 (5 s 556 ms)

build.gradle file

and no, I do not know gradle and no I am not planning on learning it, but I have no chioce. Thanks in advance

pfurbacher
  • 1,789
  • 3
  • 15
  • 23
Quapi
  • 111
  • 1
  • 2
  • 5

5 Answers5

15

I've had a similar problem with an old BungeeCord plugin, which used Gradle 4.10. In my case - it seems like that old Gradle doesn't work properly with Java 16, so I've manually changed contents of gradle/wrapper/gradle-wrapper.properties file to use Gradle 7.0.

Old file:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip

New file:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip

Now it works ok, no more Gradle errors.

Kamilkime
  • 238
  • 3
  • 7
  • 1
    After changing, I had to click "File -> Sync Project with Fradle files" to kick off the update. Probably a restart would do the same. Also, the version 7.0 was correct but is always changing, we had success picking the latest from the list at https://services.gradle.org/distributions/ – markyk Apr 16 '23 at 03:05
3

I got this error in IntellJ when opening an Android project that someone sent me. It's a Gradle error and I'm not sure of the root cause. I think it's no Gradle JVM set in the .idea folder of whoever sent me the project.

My fix was explicitly set the Gradle JVM in IntelliJ in File -> Settings -> Build, Execution & Development -> Build Tools -> Gradle and set it to 11, or whatever. It's the same fix as another answer from me over here

georgiecasey
  • 21,793
  • 11
  • 65
  • 74
0

It seems like it can be cause by different things.

I solved it changing the JDK to the embedded android JDK and adding it to the path and JAVA_HOME environement variables.

Elikill58
  • 4,050
  • 24
  • 23
  • 45
0

I faced the same error while using a download project. Here the problem is with the version compatibility of Java and Gradle. The project was using Gradle 4.10.1 and my Gradle JDK was 17 which caused the error, I just changed my Gradle JDK to version 11. This solved the error for me.

Solution: Go to File -> Project Structure -> Project. and note your Gradle Version. Gradle Version

Now go to this link: Compatibility Matrix - Gradle User Manual and look for a close enough Java version. Compatibility Matrix

Now go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. Under Gradle JDK click Download JDK.Gradle JDK

Select the version and Download then Apply. Select Download

Rebuild the Project now.

0

This issue is caused by older gradle distributionUrl. To solve it, go to gradle-wrapper.properties and replace the distributionUrl:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
Destroy666
  • 892
  • 12
  • 19