I recently installed React Native on my Windows PC and I created a project but when i try with react-native run-android for android emulator it shows me:
C:\ReactNative\testproj>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\Java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\ReactNative\testproj\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\ReactNative\testproj\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at then.result (C:\ReactNative\testproj\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
Please help
Your JAVA_HOME is set incorrectly, go through the setup again, everything should works...
You can refer to this and check what is missing...
Related
[1-npm install -g react-native-cli ]
create new project command
**react-native init MyAwesome **
run project
cd MyAwesome
connect my cellphone via laptop "developer mode and USB debugging mode is on also"
react-native run-android
C:\Users\ALL INDIA\Desktop\expMng> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:9536) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
'C:\Users\ALL' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-14.0.2\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up:
https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
You should set it with C:\Program Files\Java\jdkx.x.x.
\bin is not required.
Your android studio is not set up correctly.
Follow this to set the environment variable for android studio
https://reactnative.dev/docs/environment-setup
and do restart your PC after setup and give it a try
my english isn't that good. I am from Turkey and sorry if my question isn't clear to you.
When I run run-android with React Native, I get the following error but when I run run-ios I don't get any issue. I am using a Mac computer.
Thank you for your help.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1063 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: spawn EPERM
at ChildProcess.spawn (internal/child_process.js:407:11)
at Object.spawn (child_process.js:548:9)
at module.exports (/Users/meric/Desktop/Phonder/node_modules/execa/index.js:205:26)
at runOnAllDevices (/Users/meric/Desktop/Phonder/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:32)
at buildAndRun (/Users/meric/Desktop/Phonder/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:182:41)
at /Users/meric/Desktop/Phonder/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:146:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (/Users/meric/Desktop/Phonder/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js:186:9)
enter image description here
I think you should uninstall the app on any emulator or devices, after that please re-run app.
It might be caused by having package.lock.json and yarn.lock at the same time
////
I set jdk path in environment variables.
But the app could not be installed.
I have tried many times.
But the bugs are still there.do reply if there is any solution.
D:\React Project\MyApp>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-
jetifier"
flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_66\bin
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up:
https://facebook.github.io/react-native/docs/getting-starte
d.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (D:\React Project\MyApp\node_modules\#react-native-community\cli-platform-
android\build\commands\runAndroid\runOnAllDevices.js:94:39
)
at buildAndRun (D:\React Project\MyApp\node_modules\#react-native-community\cli-platform-
android\build\commands\runAndroid\index.js:158:41)
at D:\React Project\MyApp\node_modules\#react-native-community\cli-platform-
android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Command.handleAction (D:\React Project\MyApp\node_modules\react-
native\node_modules\#react-
native-community\cli\build\index.js:164:9)
///
Set your JAVA_HOME like This:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_66
/bin is not required.
Checkout this answer for more references.
I keep getting
ERROR: JAVA_HOME is not set and no 'java' command could be found in
your PATH
Whenever I try to run react-native code from my terminal to use an android emulator.
I've recently been trying to set up react-native on my laptop through wsl because the virtual box has been giving me trouble using it.
I've set my ANDROID_PATH to C:\Users\username\AppData\Local\Android\Sdk and my JAVA_PATH to D:\Program Files\Java\jdk-13.0.1. But I keep getting the error.
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... /bin/sh:
1: adb: not found info Launching emulator... error Failed to launch
emulator. Reason: No emulators found as an output of emulator
-list-avds. warn Please launch an emulator manually or connect a device. Otherwise, app may fail to launch. info Installing the app...
ERROR: JAVA_HOME is not set and no 'java' command could be found in
your PATH. Please set the JAVA_HOME variable in your environment to
match the location of your Java installation. error Failed to install
the app. Make sure you have the Android development environment set
up:
https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment.
Run CLI with --verbose flag for more details. Error: Command failed:
./gradlew app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (/mnt/c/users/meron/Projects/react/New_project_7/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I've tried everything but still no luck
I created the react-native project, then open the folder, at the terminal; After running "npm start" and then "react-native run-android" I was able to run it on the virtual device. However, when I do this from the vscode terminal, I get the following error;
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 4 workers...
info JS server already running.
info Installing the app...
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/home/myworldsoftware-u/İndirilenler/project2/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
npx react-native doctor
This command checks your environment and displays a report of the status of react-native installation. Check the output carefully for other software you might need to install
You should change distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
You need to make focus on 2 files to check them ..either they are present or not or the code inside them is correct...
1.local.properties file
A.check that it is present or not..if yes go to step a2 or if not then:
a1. then inside the yourAppPath/Android/ you need to make a file with name local.properties
a2. And inside that put the path of android sdk
eg: sdk.dir=C\:\\Users\\UserNameDirectory\\AppData\\Local\\Android\\Sdk
B. inside yourAppPath/Android/setting.gradle
b1. check if not present then add include ':app'
Open android folder on android studio
Then wait of gradle build to complete
Issue solved
Put below line in your android/gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread "main" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I have the same problem. At present, Android virtual machine can run normally, but running react-native run-android will cause such a problem