16

I am trying to run my android program in Qt however I am getting the following error:

Execution failed for task ':processDebugManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @13d72a22

I tried different versions of jdk and gradle however nothing helps.

Gradle version: 7.4.2 JDK version: 18

lisa.smith
  • 173
  • 1
  • 2
  • 5

6 Answers6

34

Answer for Flutter Devs

I ran into this error in IntelliJ while trying to build a Flutter app for Android. I was updating an app I had worked on almost a year ago so the com.android.tools.build:gradle dependency in android/build.gradle was way out of date.

Fixed by changing dependency to this:

 classpath 'com.android.tools.build:gradle:7.4.1'
Code on the Rocks
  • 11,488
  • 3
  • 53
  • 61
23

Adding --add-opens=java.base/java.io=ALL-UNNAMED to your JAVA_OPTS environment variable or the org.gradle.jvmargs gradle property will resolve this issue with Java 18.

Here is the full org.gradle.jvmargs gradle property value that I'm using:

org.gradle.jvmargs = -Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

Another option is to downgrade to JDK 17. I downgraded to openjdk version "17.0.3" 2022-04-19 and did not get the error.

phatblat
  • 3,804
  • 3
  • 33
  • 31
5

The Java version is too high, downgrading will solve this problem.

You can do it with following the breadcrumbs below:

File->Project Structure->SDK Location->Gradle Settings->Gradle JDK

zhxh
  • 51
  • 1
  • 3
3

I got this weird error in IntelliJ when trying to build an Android project. I think the core reason was me changing the JDK version that Gradle uses in Settings -> Build, Execution, Deployment -> Build Tools -> Gradle and Gradle JVM down there at the bottom. I tried increasing that to fix something else and got this error. Just changing back to the exact version I always used seemed to fix it. This is kind of a terrible answer but I'm going to post it anyway, it might help someone.

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

Just doing an update to the project dependencies fix this.

File > Project Structure > Suggestions

ahmnouira
  • 1,607
  • 13
  • 8
-1

For Flutter :

I downloaded 2 JDK jdk-17.0.1 and jdk-11.0.13 and add below line on gradle.properties

**For Android** : org.gradle.java.home=C\:\\Program Files (x86)\\Java\\jdk-11.0.13

**For Mac:**

org.gradle.java.home=/Applications/Android Studio 2.app/Contents/jbr/Contents/Home
shubomb
  • 672
  • 7
  • 20