putawanDE
putawanDE

Reputation: 51

Task 'installDebug' not found in project ':app' - run-android after creating project

After creating a react native project, I tried to run it on my android device. I enter adb devices into the terminal, I saw my device. I ran react-native run-android. And after a while Task 'installDebug' not found in project ':app' popped up.

Jetifier found 962 file(s) to forward-jetify. Using 4 workers
...info Starting JS server...
'D:\Android\android-sdk\platform-tools' 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...

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 15s

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=8
081

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

Here is react-native info

info Fetching system and libraries information...
System:
    OS: Windows 7 6.1.7601
    CPU: (4) x64 Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
    Memory: 881.91 MB / 3.97 GB
  Binaries:
    Node: 10.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
  IDEs:
    Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5014246
  Languages:
    Python: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.0 => 0.62.0
  npmGlobalPackages:
    *react-native*: Not Found

I ran gradlew tasks and I did not see installDebug under the install tasks. I am sure that I set up the environment variables correctly, including android SDK, JDK. I tried reinstalling react-native. I put the location of my sdk in local.properties under android folder. I ran gradlew installDebug and installDebug not found in root project '[app's name]' appeared. None of the solutions on the internet worked.

Can anyone please help me to sort out this? Thank you.

Upvotes: 5

Views: 27307

Answers (7)

Ashif AL
Ashif AL

Reputation: 549

Solution:

Run metro,

npm start --reset-cache

then run the below command,

cd android

adb reverse tcp:8081 tcp:8081 //in the android folder

then,

cd ..

npx react-native run-android

Upvotes: 2

Isaac Barrera
Isaac Barrera

Reputation: 319

Here is what forked for me on a Mac m1:

  1. npx react-native run-android raises metro terminal (stay open metro).

  2. Open project in Android in the folder android and launch Emulator on Device.

  3. Later android launch the app and Device error.

  4. Run adb reverse tcp:8081 tcp:8081 (in the android folder).

  5. In Device press reload.

Upvotes: 3

Bakersen
Bakersen

Reputation: 71

I had this same issue, and this is what I did to solve it.

  1. I deleted the android and iOS folders in my react native project.

  2. I run npx react-native eject (Incase you don't have eject, install it by running yarn add eject.

  3. I run npx react-native run-android again

Upvotes: 0

Mobarak Hossen
Mobarak Hossen

Reputation: 471

I had the same error.Try the following command, it will show the exact error of the code.

cd android && ./gradlew buildRelease

Upvotes: 0

EWR
EWR

Reputation: 126

The solution is loading the /android folder in the Android Studio and let it update the Gradle. After that you will be able to run react-native run-android

Upvotes: 5

Abbas
Abbas

Reputation: 136

I also faced the same problem. Here is what works for me.

I opened the Android Project in Android Studio. This can be located at YourReactNativeProjectFolder/android

When I opened this project in Android Studio, it was missing the configuration. Wait for some time and allow Android Studio to configure it and ask you to update the Gradle. Update the Gradle and now you can run your project from the Android Studio or using the command line "npx react-native run-android"

I hope that it will be helpful.

Best

Upvotes: 12

Andrei Vedovato
Andrei Vedovato

Reputation: 171

try the following command at the project root:

cd android && ./gradlew assembleDebug && ./gradlew installDebug

Upvotes: 2

Related Questions