Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 - android

MacBook-Air mlaapp % npx react-native run-android
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-video: https://github.com/react-native-community/react-native-video#readme
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1232 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
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
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
FAILURE: Build failed with an exception.
What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
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
at checkExecSyncError (child_process.js:631:11)
at execFileSync (child_process.js:649:15)
at runOnAllDevices (/Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:179:41)
at /Users/varmabiraju/projects/Joshi/MyProjects/mlaapp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:133:12
at processTicksAndRejections (internal/process/task_queues.js:88:5)
at async Command.handleAction (/Users/varmabraju/projects/Joshi/MyProjects/mlaapp/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js:182:9)

Try changing sdk versions in /android/build.gradle
compileSdkVersion = 30
targetSdkVersion = 30

from the comments, it seems that you are not using the gradle version 6.3. can you update your android build to use gradle 6.3 and see if the issue still persists?
another user faced a similar issue and reported this on github. you may want to take a closer look at it here.

This worked for me: Open task manager (of your OS) and kill adb.exe process. Now start adb again, now adb should start normally.

If this is your error
error for nativeDevServerPort
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
gradle 6.2 all zip causing this error for run-android please change or upgrade the distributionUrl version of gradle in
gradle-wrapper.properties to
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
Hope this could help you in installing your react-native application in android

Related

Build Failed in react native

I was working with react native in my windows 10 for months. after upgrading to windows 11 and installing previous tools , I am not able to run my react native project . I installed android studio , SDK, JDK, node and other tools like before. but I got this error after running npx react-native run-android command:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Username\Documents\React Native Projects\myapp\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
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 38s
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
Note: C:\Users\Username\Documents\React Native Projects\myapp\node_modules\react-native-gradle-plugin\src\main\java\com\facebook\react\codegen\generator\SchemaJsonParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Username\Documents\React Native Projects\myapp\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
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 38s
at makeError (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\Username\Documents\React Native Projects\myapp\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 (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (C:\Users\Username\Documents\React Native Projects\myapp\node_modules\#react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
This question was asked many times before, but I did not get an answer from them . I tried gradlew clean but I get same error (Build Failed). for some developers chmod +x gradlew worked. but it is for Linux and Mac. I am using windows . is there any replacement command for windows or other way to fix this problem ?
thanks .
Open Android Studio Settings and follow this path. Open the dropdown for Gradle JDK and select 11 from the dropdown.

Error when trying to run an android app that uses react-native-camera

Hi i'm trying to use the camera with react-native-camera in react native but when i run the app it shows this error
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1165 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
> Task :react-native-camera:compileMlkitDebugJavaWithJavac 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
98 actionable tasks: 2 executed, 96 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-camera:compileMlkitDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
* 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 10s
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 ':react-native-camera:compileMlkitDebugJavaWithJavac'.
> Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home contains a valid JDK installation.
* 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 10s
at makeError (/Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Users/calebgarcia/Dev/Tibeo/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/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/calebgarcia/Dev/Tibeo/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
I've had a lot of problems when trying to run the react native apps on android but in ios they run perfectly.
Do you guys have any idea how can i solve the error.
Thanks
firstly check whether what jdk version you have installed (got to terminal and check by java --version)
make sure u have added that jre path to your environment variables
if these condition already u have done then follow below link
[https://dev.to/larrydanny/could-not-find-tools-jar-4363][1]
your proble will be solved....

React Native Issue while setting up new Project macOs

$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
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 669ms
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 app:installDebug -PreactNativeDevServerPort=8081
But it was running perfectly on ios simulator only problem while running or android emulator
In gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip

React Native not detecting Android emulator

When I do react-native run-android I get this error:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 960 file(s) to forward-jetify. Using 6 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...
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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
* Try:
Run gradlew tasks to get a list of available tasks. 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 4s
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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Task 'installDebug' not found in project ':app'.
* Try:
Run gradlew tasks to get a list of available tasks. 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
I dont get it, before I run my React Native app I open the Android emulator first. I also noticed that my android studio doesn't have 'configure' on welcome page, so I have to start a project if I want to acces the sdk manager and avd manager.
Try in the same terminal that you put npx react-native run-android , set environment variables again like :
source $HOME/.zprofile (if you use zsh)
source $HOME/.bash_profile (if you use bash)

How to fix if the react native android build is failed?

I am very new to React native app developer. Please help me to fix the below issue
I am facing the below issues while executing react-native run-android.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1112 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
'adb' 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...
Starting a Gradle Daemon (subsequent builds will be faster)
Task :app:processDebugResources 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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
92 actionable tasks: 4 executed, 88 up-to-date
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat' after 10 attempts
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 43s
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: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Unable to delete directory 'E:\React Native\RNProjects\AHHCSTAFF\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx\appcompat' after 10 attempts
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 43s
at makeError (E:\React Native\RNProjects\AHHCSTAFF\node_modules\execa\index.js:174:9)
at E:\React Native\RNProjects\AHHCSTAFF\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (E:\React Native\RNProjects\AHHCSTAFF\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (E:\React Native\RNProjects\AHHCSTAFF\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:186:9)
I dont know how to fix all the above issues
I have met this error logs before. Here are my resolve steps:(executing in progect root dictory)
cd android
gradlew clean
And run yarn android,it works well.By the way,my RN version is 0.62. You can have a try.

Categories

Resources