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 @786f3609
I had the same issue and I resolved it by appending
org.gradle.jvmargs=--add-opens java.base/java.io=ALL-UNNAMED
To the file :
./android/gradle.properties
Choose JDK Location to lower than Java 16, as it is not supported in Android studio as of now.
/usr/libexec/java_home -v 11.0.15.1
–
Sierra 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
This Issue occur due to :-
The error message you're seeing indicates that you are trying to access or modify a private final field (java.io.File.path) in the java.io package, but the module system is preventing such access.
How I solved this issue :-
Steps :- Click on files-> Settings -> Build, Execution and Deployment -> Build Tools -> Gradle -> Then select the jdk 11.
I used this version
Then Clean and Rebuild your project and you good to go now.
If you've encountered an "Invalid Keystore Format" error in Android Studio and you recently upgraded your JDK to version 20, downgrading to JDK 11 help resolve the issue. Follow these steps to get your project back on track:
Uninstall Current JDK: if you've recently installed a higher version of the JDK (e.g., JDK 20), uninstall it from your system.
Download JDK 11 Visit the official Oracle website and download JDK 11. Please note that JDK 11 might require an Oracle account for downloading, as it's an older version. but no worries you can create you oracle account just within 2 minutes.
Install JDK 11
In Search Bar of Windows Search Environment Variables and click on environment variables:
In System variable Windows of Environment Variable Click on Path and Click Edit, then go to the bin directory of Java jdk folder (e.g., C:\Program Files\Java\jdk-11\bin). Copy this path and paste below previous paths. In the same environment variables window, click on NEW in system variable in name enter JAVA_HOME and set its value to the JDK 11 home directory (e.g., C:\Program Files\Java\jdk-11).
Now go to your android studio project
Go to "File" > "Project Structure."
in Gradle Settings Select the JDK 11, as you installed and added to environment variable so it will appear there.
Rebuild your project adn you're good to go.
© 2022 - 2024 — McMap. All rights reserved.