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

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

Related

React native android emulator Task :app:packageDebug FAILED error

I got this error while react-native run-android. I tried ./gradlew clean ./gradlew -stop and wipe data, remove build folder, .gradle folder etc... But can't solve the problem.
Here is the error code I got.
Does anyone has an idea to solve that problem?
$ react-native run-android
warn Package #svgr/webpack has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in (...)/node_modules/#svgr/webpack/package.json
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1888 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon, 1 incompatible and 3 stopped Daemons could not be reused, use --status for details
> Configure project :lottie-react-native
WARNING:: The specified Android SDK Build Tools version (29.0.3) is ignored, as it is below the minimum supported version (30.0.2) for Android Gradle Plugin 4.2.2.
Android SDK Build Tools 30.0.2 will be used.
To suppress this warning, remove "buildToolsVersion '29.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
> Task :app:packageDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
495 actionable tasks: 5 executed, 490 up-to-date
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
(...)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> com.android.ide.common.signing.KeytoolException: Failed to read key androiddebugkey from store "(...)/android/app/debug.keystore": keystore password was incorrect
* 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 14s
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
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
(...)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
> com.android.ide.common.signing.KeytoolException: Failed to read key androiddebugkey from store "(...)/android/app/debug.keystore": keystore password was incorrect```

What went wrong: java.io.IOException: The filename, directory name, or volume label syntax is incorrect

I just started learning react-native a couple days ago, and I got a bug during installation and setting up. The moment I run the cmd "npx react-native run-android", and I got this error.
Jetifier found 896 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
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.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.''
Please help me guys. Thank you very much.
Might be the issue with the incorrect SDK location. Can you verify if there is a local.properties in your android folder under your React Native project with right sdk location path in it
Also verify the below code in gradle-wrapper.properties present in gradle/wrapper folder
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-
all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

How could I launch the application without using "expo and emulator"

[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

Hi guys I keep getting the error ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH

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

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