I am new to React and first tried to do a Hello World Project. I got the mentioned error but also the error, that my sdk path is not set. So I configured a ANDROID_SDK_ROOT
variable. Then it worked properly.
Now I want to run the rocket chat app from github on my android device. This is the project: https://github.com/RocketChat.
After navigating into the project (root), I first started the server with npm start
, showing me a successful message. Then I wanted to run it on my phone, using npx react-native run-android
.
This is the output I get:
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 1m 5s
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
I know there are already some posts about this error and I tried their solutions so far, but without success yet.
My device is registered and is showing when I do adb devices
. The global android sdk variable is also set.
What could have gone wrong? Can someone tell me what I am missing?
Thanks for every help!
I fixed it. None of the solutions worked but I found another way.
First, dont forget to start the server. Navigate to the root folder of your project and run npm start
. This should run successfully. If it says your ports are already used, just open your task manager and terminate all tasks from NodeJS.
In your android folder, run the command gradlew tasks
. This will show you a list of available commands. I dont know why, but the command installDebug
was not there, hence the error.
But there were other tasks which sounded similar, for example installFossDebug
.
So I ran npx react-native run-android --variant=installFossDebug
. But it didnt work. The console showed me a new error, saying Task installInstallFossDebug could not be found
(No Typo).
I dont know why install
was twice in the task, so I just ran npx react-native run-android --variant=FossDebug
and voila, it worked. The app started successfully on my android device.
Good luck! :-)