16

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

appersiano
  • 2,670
  • 22
  • 42
Abanob Emad
  • 161
  • 1
  • 1
  • 4

4 Answers4

21

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

Axay Prajapati
  • 791
  • 5
  • 20
  • 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.1` – Daniel Sep 15 '22 at 16:10
20

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
17

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
phatblat
  • 3,804
  • 3
  • 33
  • 31
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.

P.S. I managed to rescue my Final Year Project just hours before my Challenging Final Defense Presentation. This process saved me from the brink of despair, and I've delved deep into the arcane arts of research to share this gem with you. May your future endeavors be as epic as this adventure!

JAWAD KHAN
  • 61
  • 7