'Java module not acessible

I'm trying to run an app in react native and it worked the first time, however it doesn't now, I installed jdk and it correctly.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> 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 @2ecd0db5

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

    at makeError (/Users/fovu/Documents/React Native Projects/AwesomeProject/node_modules/execa/index.js:174:9)
    at /Users/fovu/Documents/React Native Projects/AwesomeProject/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/Users/fovu/Documents/React Native Projects/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/usr/local/lib/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:192:9)


Solution 1:[1]

I upgraded to JDK 18 and was seeing this error. Could also be a problem for JDK 16+.

I resolved by appending

org.gradle.jvmargs=--add-opens java.base/java.io=ALL-UNNAMED

To the bottom of the following file:

./android/gradle.properties

Source for fix: First React Native App: Task :app:processDebugMainManifest FAILED

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dylan w