Execution failed for task ':app:installDebug' MOST of TIMES [duplicate] - react-native

This question already has answers here:
react-native :app:installDebug FAILED
(35 answers)
Closed 9 days ago.
There are quite a few online posts about the error. My situation is that I can make the connection sometimes but failed most of times. Here is the error when failing:
PS C:\d\code\js\chatapp> react-native run-android
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* 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 15s
27 actionable tasks: 1 executed, 26 up-to-date
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
Here is the message when success:
PS C:\d\code\js\chatapp> react-native run-android
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
> Task :app:installDebug
Installing APK 'app-debug.apk' on 'MHA-L29 - 8.0.0' for app:debug
Installed on 1 device.
BUILD SUCCESSFUL in 6s
27 actionable tasks: 1 executed, 26 up-to-date
'adb' is not recognized as an internal or external command,
operable program or batch file.
Starting the app (c:\AppData\Local\Android\Sdk/platform-tools/adb shell am start -n com.chatapp/com.chatapp.MainActivity...
Starting: Intent { cmp=com.chatapp/.MainActivity }
I don't have good explanation why sometime it did work and other time it did not. Before each react-native run andrioid, USB Debugging is enabled on Mate 9.

This would also happen to me when the phone I had connected had a locked screen. Make sure the phone is 'active' when you're trying to run. Before you run react-native run-android you can use "adb devices" command to list all connected devices. Make sure there is only one at time (no emulator running as well).
Last thing I can recommend is update React Native. They are doing a great job improving with each version and it might happen you will never see this error again in the newest version. Good luck!

I had a similar issue and just posted a solution that worked for me here - https://stackoverflow.com/a/67566428/10392546
I ran into a similar issue, not sure if you get it fixed, but I came accross this post when looking for solutions and the above solution didn't work for me.
A solution I did find out about was to install android-emulator-m1-preview from google, launch that instead of launching the emulator from inside Android Studio. Its almost annoying how simple of an issue it turned out to be to fix.
Seeing build successful after 12+ hours of trying different solutions is really nice.

I have this issue with my project. I have tried many ways to solve that and I have so many guidelines in stackoverflow, github, blog articles. But there was a mistake I made within the process. So make sure you are do things withing the debugging period.
runcd android && ./gradlew clean && ./gradlew :app:bundleRelease
make sure in each action wipe data in emulator
If you are trying with the external device make sure it is online or unlock the screen.

Try uninstalling the package from your phone. Sometimes this data is cached in your phone memory. You can use the following commands.
List adb devices connected to your computer. Head over to the terminal in your the project root directory and run adb devices. This will list all the devices attached.
Your result will look something like this;
$ adb devices
List of devices attached
047292599G105335 device
Then run adb -s <your_device_key> uninstall <your_package_name>.
<your_device_key> in this case is is 047292599G105335 and the package name looks something like com.appname, all without the square brackets.
So in my case it looked like adb -s 047292599G105335 uninstall com.appname
Now run your project again react-native run-android

Related

Expo won't start the simulator / emulator

I always used to start my Expo project by typing in the terminal expo start and then i (for iOS simulator). The day after iOS 16 got released, Expo started to behave differently. After running expo start it gave me a warning: This command is being executed with the global Expo CLI. Learn more: https://blog.expo.dev/the-new-expo-cli-f4250d8e3421
To use the local CLI instead (recommended in SDK 46 and higher), run:
› npx expo start and after pressing i it threw the following error:
Error running xcrun simctl help: You may need to run sudo xcode-select -s /Applications/Xcode.app and try again.
XDLError: You may need to run sudo xcode-select -s /Applications/Xcode.app and try again.
Unable to verify Xcode and Simulator installation. After this I killed the terminal and in a new one I decided to follow the command it gave me in the warning (after running expo start). I ran npx expo start and then i and it threw me a new error which was:
Unable to run simctl:
Error: xcrun exited with non-zero code: 72
CommandError: xcrun is not configured correctly. Ensure sudo xcode-select --reset works before running this command again., but this time it didn't gave me a warning before pressing i. I also tried to run the commands shown in the errors and re-run the app, but still the same errors were thrown. I updated my OS, XCode and also deleted and cloned the project again so i could re-install dependencies just in case something was wrong with them.
I have attached the GitHub repo link of one of my projects so you can test it as well. It's not just this project, it's all of the projects I use Expo, even the new ones won't start.
If anyone has any idea how to fix this and why this happens, I would really appreciate it :)
Uninstalled and re-installed Expo globally. Updated the simulator to iOS 16 and opened the simulator before running expo start. It works as it did before.

How can I run android app on from react native

I am facing error while running react native cli to emulator by using android studio
Actual output
Manifest merger failed with multiple errors, see logs
expected output
Running app on. android emulator
with custom app launch icon
actual output with VSCode
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
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed with multiple errors, see logs
* 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
since the port is mentioned it looks a little bit like you are not connected and need to reconnect your adb server to the application on metro. To do so you need to install adb tools (I believe it was via brew, but google will help) and then run(in 2nd Terminal beside metro):
adb reverse tcp:8081 tcp:8081
When it shows 8081 in the new terminal, you can try again.

native_modules.gradle file is deleting as soon as react-redux is installed

I have created an app in react native for my project. When I copy my projects file in the app folder then run the app it said that in node_module react-redux does not exist then I installed react-redux using npm install react-redux#7.0.3 in my app folder after that when I run run-android command in command prompt for this project it is telling that -
Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist. .
After that, I wiped the data of emulator and run run-android, but it is still giving me the same error and app is not installing in the emulator.
Here is the error which command prompt is displaying :
info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Settings file 'E:\AppFolder\MyApp\android\settings.gradle' line: 4
* What went wrong:
A problem occurred evaluating settings 'TribeBond'.
> Could not read script 'E:\AppFolder\MyApp\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' as it does not exist.
* 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 1m 10s
error 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
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.```
Here I follow these steps to solve my problem-
I build a new app and run it using react-native run-android command.
Then I installed all dependencies one by one, which is going to use in the app.
Then run npm install command in the project.
After that, I re-build the app using react-native run-android.
And Tada! the app is re-built without any error.

React Native not working

I am working on react native and building my app on android pyhsical device but it throws an error.
I have set my JAVA_HOME and ANDROID_HOME variabes but still not working.
This is exactly what it is returning :-
Scanning folders for symlinks in /home/harsh/Desktop/App/node_modules (9ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '10.0.1'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
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
Your error may come from the fact that you have 2 differents jdk installed and, since react should not be used with a jdk > 9 yet, check your Java installation with java -v in order to get the version.

Android build error: Cannot evaluate module RCTVideo : Configuration with name 'default' not found

I'm trying to get set up using https://github.com/brentvatne/react-native-video for an android version of a react-native app. After making all the changes to the various gradle files I'm running into this issue below.
I'm a bit of a novice with Android development, and I think I'm just making a silly mistake which is why I'm asking the question here rather than raising an issue. Any advice would be appreciated!
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Cannot evaluate module RCTVideo : Configuration with name 'default' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.851 secs
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/android-setup.html
Edit, settings.gradle looks like this:
rootProject.name = 'app_name'
include ':RCTVideo', ':app'
project(':RCTVideo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
Without seeing the Settings.gradle my guess would be that the project location isn't going into the folder that has the gradle for the android version of the library. I would recommend added /android at the end of the path if it isn't there already.
I will update this answer when the Settings.gradle is provided.
-- Edit after additional information provided --
The version available on NPM is from 3 months ago. It looks like they didn't start adding Android support till Oct 30th and have continued working on it. As such you likely don't actually have the Android code in your node_modules folder. You can either wait till they push an update to NPM or install directly from the git repo. If you go the route of installing directly from the git repo you might want to tag it with a specific commit so you don't keep getting the latest every time you do a npm install.