Unable to make field private final java.lang.String java.io.File.path accessible
Asked Answered
C

5

25

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 enter image description here

Complaint answered 23/7, 2021 at 14:33 Comment(0)
U
33

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
Ultramontanism answered 9/5, 2023 at 8:12 Comment(3)
Thank you so much! I was struggling since yesterday after upgrading to the latest flutter version and then got this error. Only this solution worked!Keon
thanks! I have no idea how we programmed back in the days without SO.Klutz
Welcome Billy, I am happy that I could help you here, it was harder obviouslyUltramontanism
M
22

Choose JDK Location to lower than Java 16, as it is not supported in Android studio as of now.

Mesh answered 28/7, 2021 at 4:50 Comment(1)
I got this when running fastlane to build an ionic project. It built manually in studio, but not from fastlane. Fix was to include this before running fastlane, to ensure correct path (on MacOS Monterey) export PATH=$HOME/.fastlane/bin:$PATH && export ANDROID_HOME=~/Library/Android/sdk && export PATH=${PATH}:${ANDROID_HOME}/tools && export PATH=${PATH}:${ANDROID_HOME}/platform-tools && export JAVA_HOME=/usr/libexec/java_home -v 11.0.15.1Sierra
W
20

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
Whitver answered 26/5, 2022 at 17:25 Comment(0)
M
4

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.

Marbleize answered 17/1 at 5:52 Comment(0)
U
0

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:

  1. Uninstall Current JDK: if you've recently installed a higher version of the JDK (e.g., JDK 20), uninstall it from your system.

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

  3. Install JDK 11

  4. In Search Bar of Windows Search Environment Variables and click on environment variables:

  5. 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).

  6. Now go to your android studio project

  7. Go to "File" > "Project Structure."

  8. in Gradle Settings Select the JDK 11, as you installed and added to environment variable so it will appear there.

  9. Rebuild your project adn you're good to go.

Unburden answered 16/8, 2023 at 12:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.