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

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.

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

try the following command at the project root:
cd android && ./gradlew assembleDebug && ./gradlew installDebug

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

I had the same error.Try the following command, it will show the exact error of the code.
cd android && ./gradlew buildRelease

for me => Mac m1
1.- npx react-native run-android raises metro terminal(stay open metro).
2.- open proyect in Android in the folder android and launch Emulator on Device.(wait....).
3.- later android launch the app and Device error.
4.- in terminal type 'adb reverse tcp:8081 tcp:8081'(in the folder android).
5.- in Device press reload
sorry my English =)
and I hope it will help them

Related

React-native run-android is not working because it cant found any emulators macOS

I created react-native project and when I run react-native run-ios it is working perfectly.
But the problem is android.
Whenever I run react-native run-android it gives me this error:
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
After this error it begins to install the app and in the end I get this error.
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
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
I installed latest java and jdk tools.
I found some solutions on stack overflow and I followed one which suggested to clean Gradlew file in the android folder but it did not work either.
any suggestions please?
My OS is macOS Catalina
Just in case anyone encounters this problem.
I solved it this way
1.ANDROID STUDIO
I went to the android studio and updated all the tools needed for the emulator
2.Android folder inside the project
I went to the android folder of my project, inside of android/app/gradle Gradle-wrapper file and updated distributionUrl to the latest version
3.Clear cache
I ran npm --reset-cache start
4.Final step
After all of this I opened android emulator and ran react-native run-android in my app and it worked

React Native: fail while installing the "app". Error at executing gradlew.bat

​Well, I am trying to install all components to run React Native apps on my computer, but I have been working on this for four days and I always got the same error message:
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 reinstalled the components three times, but only some things changed, like the time that jumped from 30 minutes to 3 hours, and the quantity of text that shows on my screen.
​I tried a lot of solutions I found on the internet, like uninstall the global react-native-cli and use .\gradlew clean however it did not work because I got a message saying that "." is not recognized like a command. I really do not know how to correct it...
Bellow, my computer configurations:
System: Windows 7 professional SP1
Processor: Intel Atom CPU D525 #1.80Ghz 1.79GHz
RAM memory: 2,00GB
Type of system: 32-bit operating system
The React Native component versions I installed:
Chocolatey: v0.10.15
Node.js: v12.13.0
Npm: 6.12.0
Yarn: 1.22.5
Python: 2.7.18
JDK 8: 1.8.0_271
Android Studio: 3.6.3
Observations:
I also have Python 3.8 installed
I also tried the command line tools only before the Android Studio IDE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Unknown failure: Exception occurred while executing:
android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space
at android.util.ExceptionUtils.wrap(ExceptionUtils.java:34)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:413)
at com.android.server.pm.PackageManagerShellCommand.doCreateSession(PackageManagerShellCommand.java:2418)
at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:907)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:158)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22015)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:2809)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4070)
at android.os.Binder.execTransact(Binder.java:731)
Caused by: java.io.IOException: Requested internal only, but not enough space
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:232)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:148)
at com.android.internal.content.PackageHelper.resolveInstallVolume(PackageHelper.java:163)
at com.android.server.pm.PackageInstallerService.createSessionInternal(PackageInstallerService.java:510)
at com.android.server.pm.PackageInstallerService.createSession(PackageInstallerService.java:411)
... 10 more
* 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 1h 47m 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.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\myusername\Desktop\appproject1\android\app\src\debug\java\com\appproject1\ReactNativeFlipper.java uses or overrides a deprecated API.
C:\Users\myusername\Desktop\appproject1>
​ I apologize for not being able to give you more information. I ask you to help me, please.
Edit:
I would like to give some tips about problems I got when trying to use react-native:
Low space on the smartphone. Please try to install something in the store, if you cannot do it, you need to free some space.
Some problems could be solved only by trying to run the project by Android Studio, please try it too.
Cache may be your problem. Try it inside the project folder:
cd android
gradlew clean
after it, run the project again returning to the project folder using cd ..:
cd ..
react-native run-android
Issue:
> Caused by: java.io.IOException: Requested internal only, but not enough space
solution -1-
replace
android:installLocation="internalOnly"
with
android:installLocation="preferExternal"
solution -2-
make some space on the device / emulator

react-native run-android Fails MacOS

Complete Console Output is below
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 8 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 696ms
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 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 696ms
at makeError (/Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:174:9)
at /Users/user/Desktop/sa/MyReactApp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/Users/user/Desktop/sa/MyReactApp/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/Users/user/Desktop/sa/MyReactApp/node_modules/#react-native-community/cli/build/index.js:186:9)
Bash_profile
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=$HOME/.android/avd
alias emulator='$ANDROID_SDK_ROOT/tools/emulator'
Requested Attachments
Android SDK Link From Android Studio
SDK Tools Installed
npx #react-native-community/cli doctor Result
Installed Android Emulator
Nexus 6P (Android R and Pie)
New To React Native
it works perfectly on iOS
but it fails to launch in Android Simulator
Tried Ways
npm start
npx react-native run-ios
npx react-native run-android
It is Probably because of JDK version as mention above.
You can verify by running react native doctor
npx #react-native-community/cli doctor
Install JDK 1.8 and setup $JAVA_HOME env variable and try to run the app again.
The error is due to lower version of JDK or JDK not installed.
your problem can be resolved just follow these steps:
To jetify / convert node_modules dependencies to AndroidX
Imagine you have a react-native project. One of your library dependencies converts to AndroidX., and you need to use the new version.
So now you need to convert your app to AndroidX, but many of your react-native libraries ship native Java code and have not updated. How is this done?
First, use Android Studio's refactoring tool to convert your app re: the Android developer docs
npm install --save-dev jetifier
npx jetify
npx react-native run-android (your app should correctly compile and work)
Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again
you can follow this link as well: https://www.npmjs.com/package/jetifier
feel free for any confusion.
This link is the complete solution but here is a little problem if you have win32 but if you have win64 you are good to go.
**https://www.npmjs.com/package/jetifier#do_you_need_this**
hope this answer will be useful for you
feel free for any problem.
The error is due to the version of JDK or JDK not installed.
i think you need to solve in the section:
open the androind folder with android studio
then file-> project structure -> SDK location
and in here you can change, in my case i change the version
before that, for to know what was the error:
i realized what is the problem with this command
npx #react-native-community/cli doctor
i got these errors:
Please make changes as per below to resolve this error.
Install Java SDK version: 14 or above.
JDK Download link: https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
In gradle-wrapper.properties please use grade version 6.3 or above.
For e.g:distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

ERROR: An error occurred while running subprocess cordova

I build an app on Ionic framework, it works on the browser but when I try to compile it on the emulator I have got this error:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\user\AppData\Local\Android\Sdk (DEPRECATED)
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.3.1/userguide/gradle_daemon.html
Process command line: C:\Program Files (x86)\Java\jdk1.8.0_201\bin\java.exe -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=SA -Duser.language=ar -Duser.variant -cp C:\Gradle\gradle-5.3.1\lib\gradle-launcher-5.3.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.3.1
Please read the following process output to find out more:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
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
C:\Gradle\gradle-5.3.1\bin\gradle: Command failed with exit code 1
[ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
This is because the path to Android Sdk is not set correctly. Please check the correct path for Sdk, tools, platform-tools, emulator and Android build-tools.
Please, realize that the configuration recommended for Ionic has changed a
bit. Now the notation recommended is as follows:
ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)
In Linux or Mac OS X configure the path into the ~/.bashrc, ~/.bash_profile file:
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools
At the end, after save the configuration dont forget to do the command:
source ~/.bashrc
or as your case
source ~/.bash_profile
For the Windows users check the global variables.
Try to Run npm cache clean and re-install cordova...worked for me.
I finally found the solution from a related solved topic: The solution is:
ionic platform rm android
ionic platform add android#latest
ionic resources
ionic run android
ionic repair worked for me. Just give it a try and see if that works for you. Good luck!

Execution failed for task ':app:compileDebugJavaWithJavac' react native

I am trying to run react native app on my android device like this in cmd
cd C:\Users\User\Desktop\js
react-native run-android
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not find tools.jar
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: 5.243 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
Can anyone please tell me how to fix this problem?
Use the following step once, it may help you:
step 1: open cmd through administrator
step 2: navigate to your application by cd <path to your project>
step 3: run this command: ./gradlew clean
step 4: react-native run-android
Have you installed JDK and Android SDK properly? Are the JAVA_HOME and ANDROID_HOME properly placed in your environment variables?
I faced this issue while working on react-native project on Linux.
In my case issue occured because I linked some external plugin and then removed it without unlink. In that case you can attentively read your console error message. It should point to place that source an error.
The solution if ur version of react-native >= 0.61.0. It shows error as when we add any plugin and use link command then it makes changes in android and ios folder. But when we remove plugin, it gets removed from package.json but inside android changes are not reverted and it gives error. So use below command to generate android folder again.
I hope it will solve the error-
sudo rm -rf android/ ios/
yarn add react-native-eject
npx react-native eject
If you are working with react native, just make sure you set up environment variables correctly for java compiler.
after this goto package.json file in your project:
change this:
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
to:
"react-native": "0.57.5",
save and run npm install
Source: https://github.com/facebook/react-native/issues/21722

Categories

Resources