I am trying to setup environment for React Native on my Mac M1. But i am getting these error while trying to run android.
yarn android
yarn run v1.22.17
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 863 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 2 executed, 9 up-to-date
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 @303b4750
* 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 3s
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 @303b4750
* 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 3s
at makeError (/Users/nitesh/Desktop/RN/rncontacts/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Users/nitesh/Desktop/RN/rncontacts/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/nitesh/Desktop/RN/rncontacts/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/nitesh/Desktop/RN/rncontacts/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I have setup Apple Silicion version of Android Studio Bumblee Bee. I have stored path variables also. I am using terminal in rosetta. What is the cause of this? and how to fix this?
CodePudding user response:
For Windows Try installing with chocolatey. With this the path is set automatically and right way. https://chocolatey.org/install
You can find videos on YT to how to install it.
and then read react native docs again there is an option to install with chocolatey by using choco keyword
IOS You can set environment variable. For me (I use zsh), it's .zshrc file in my root directory where I set the environment variable.
Example:
In .zshrc file add the next line:
export PATH_TO_SOME_FRAMEWORK="some/local/path"
And after that you can use environment variable in podfile this way:
target 'SomeTarget' do
pod 'SomeFramework', :path => ENV['PATH_TO_SOME_FRAMEWORK']
end
CodePudding user response:
Looks like you are having JDK issues: Refer to this: https://stackoverflow.com/a/70807648/8460837 Basically, you might need to downgrade your jdk version, your current gradle version is not compatible with your JDK Version.