gradlew.bat installDebug error while runing react-native code on device - react-native

Whenever I create new project in react native it works fine and runs on android device but when I install "React Navigation 3.x" library in my react native app and try to build it on my device I got the following error
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:622:11)
at Object.execFileSync (child_process.js:640:13)
at runOnAllDevices (E:\ReactNative\awesomeproject\node_modules\react-
local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (E:\ReactNative\awesomeproject\node_modules\react-nati
l-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (E:\ReactNative\awesomeproject\node_
\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process.internalTickCallback (internal/process/next_tick.js:77:7)

Go inside your android directory and use this ./gradlew clean, after this you will see an error about you are missing the sdk path. Inside the android directory create a new file local.properties and write down there the sdk path, Windows: sdk.dir=C\:\\Users\\YOU_USERNAME\\AppData\\Local\\Android\\sdk the same thing for MAC with a different path (check the path with android studio)

Related

Android development environment set up issue came while trying to run react native app

I am currently trying to run react native application but I am getting this error in windows 10.
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_251;
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:630:11)
at execFileSync (child_process.js:648:15)
at runOnAllDevices (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:179:41)
at C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:133:12
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Command.handleAction (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:182:9)
I already install java and its working like in this image
Also, I run emulator before using this code react-native run-android like in this image
it also giving me this error but the emulator working.
Failed to open /qemu.conf, err: 2
What the wrong move that I did in this situation?
You can checkout the same question at this. Edit your environmental variable.
Go to User Variables and Edit the path and add %JAVA_HOME%\bin.
Now in your system variable environments: edit the path and click new and add this C:\Program Files\Java\jdk1.8.0_241\bin
Again in system variable environment click on the path and click on new add this line C:\Program Files (x86)\Common Files\Oracle\Java\javapath
Now save and restart your system. this would help you.
You need to setup the JAVA_HOME environment variable that will be called when running react native android build.
Setup guide for JAVA_HOME.

Problem encountered in react native run android

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...

Error Failed to install the app. Make sure you have the Android development environment set up

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

getting error gradlew.bat installDebug after installing react navigation and gesture handler

I create the new react native app using command react-native init appName.
After the app created successfully install it in my device using command react-native run-android, it installed successfully, and works fine... no issue
but as soon I install react navigation and gesture handler I am getting the error that Command failed: gradlew.bat installDebug after running command react-native run-android
I don't know what's wrong... my old react native projects are working perfectly fine.
I remember yesterday I run the command gradlew clean in one of my old project.. is this effecting on my new project?
I would be really thankful if someone helps
This is complete error
FAILURE: Build failed with an exception.
* Where:
Settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle' line: 3
* What went wrong:
Could not compile settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle'.
> startup failed:
settings file 'D:\React Native Apps\Practice\newapp\android\settings.gradle': 3: unexpected char: '\' # line 3, column 133.
s\react-native-gesture-handler\android')
^
1 error
* 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 1s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: gradlew.bat installDebug
Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:616:11)
at Object.execFileSync (child_process.js:634:13)
at runOnAllDevices (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
at isPackagerRunning.then.result (D:\React Native Apps\Practice\newapp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
Oh yeah, it´s a bug i think with RN 0.58 link command
open settings.gradle with a text editor from => 'D:\React Native Apps\Practice\newapp\android\settings.gradle'
replace all '\' with '/' , in my case i had to replace '..\node_modules\react-native-gesture-handler\android' with '../node_modules/react-native-gesture-handler/android'
then react-native run-android
Make sure you already have installed python 2 and last version of jdk And make sure you have already set ANDROID_HOME
And you should follow this structure : https://facebook.github.io/react-native/docs/getting-started.html

ReactNative fails to deploy build to iOS simulator but does deploy it to Android emulator

ReactNative fails to deploy build to iOS simulator but does deploy it to Android emulator
Attached are screenshots showing this on both.
Steps:
Created react native app
react-native init proto
Run app on Android emulator after I started emulator
react-native run-android
this is running fine on Android emulator
Run app on iOS simmulator
react-native run-ios
This produces error as per screenshot
Error
** BUILD FAILED **
The following build commands failed:
CompileC /Users/dinob/reactnativework/proto/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/React.build/Objects-normal/x86_64/RCTShadowView+Internal.o Views/RCTShadowView+Internal.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/proto.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/proto.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Versions
MacBookPro OSX El Capitain
react-native 0.55.3
react-native-cli 2.0.1
npm 5.5.1
node v8.9.1
watchman 4.9.0
Please have a look here for help with troubleshooting
I would suggest you try all the solutions described in that thread to try and fix this issue. Good Luck!