简体   繁体   中英

JAVA ERROR: React native basic project not working in android studio

I'm followed all the steps from this document to install and run react native project in android studio.

https://reactnative.dev/docs/environment-setup

When I run the command npx react-native run-android to run the project in emulator, I got below error in terminal.

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 901 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 11 executed

FAILURE: Build failed with an exception.

* 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 @6353fde6

* 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 16s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* 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 @6353fde6

* 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 16s

    at makeError (/var/www/html/test_native/node_modules/execa/index.js:174:9)
    at /var/www/html/test_native/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async runOnAllDevices (/var/www/html/test_native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/var/www/html/test_native/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)
info Run CLI with --verbose flag for more details.

Environment:

Ubuntu 16.04
Node 14.15.4
Java 16
Latest Android Studio

Environment variable:

JAVA_HOME="/usr/lib/jvm/jdk-16"

ANDROID_SDK_ROOT="/home/dev-21/Android/Sdk"

ANDROID_HOME="/home/dev-21/Android/Sdk"

Had the same problem today, and what worked for me was downgrading to java 14, based on this suggestion: https://stackoverflow.com/a/66951023/1021253

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM