-1
Guys, I’m having trouble starting an React Native project while running the command npx react-native run-android. The mistake is:
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 4 workers...
info JS server already running.
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 3s
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
BUILD FAILED in 3s
at makeError (/home/temp/react_native_project/node_modules/execa/index.js:174:9)
at /home/temp/react_native_project/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/home/temp/react_native_project/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/home/temp/react_native_project/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)
There’s something about Gradle 7.0, but I can’t fix it. My environment is:
- Linux 5.6.11-zen1-1-zen
- React-Native-cli: 2.0.1
- React-Native: 0.62.2
Edited: dicing package.json
{
"name": "react_native_project",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.11.0",
"react-native": "0.62.2"
},
"devDependencies": {
"@babel/core": "^7.10.1",
"@babel/runtime": "^7.10.1",
"@react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^26.0.1",
"eslint": "^7.1.0",
"jest": "^26.0.1",
"jetifier": "^1.6.5",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}
Command information: android/gradlew --version
-----------------------------------------------------------
Gradle 6.0.1
------------------------------------------------------------
Build time: 2019-11-18 20:25:01 UTC
Revision: fad121066a68c4701acd362daf4287a7c309a0f5
Kotlin: 1.3.50
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_242 (Oracle Corporation 25.242-b08)
OS: Linux 5.6.11-zen1-1-zen amd64
Solved:
I had to create the project with the npxand create archive local properties. in android folder with contents sdk.dir=/home/gui/Android/Sdk. Done that, everything worked.
If you run
./gradlew tasksbeforereact-native run-androidworks? Here has other suggestions.– Rafael Tavares
No, it didn’t work. I ran a
./gradle clean, I removed the folder ~/.Gradle and then the node_modules of my project. I executed thenpm installand./gradle tasksin the project, and when I runnpx react-native run-androidI’m facing the same mistake.– Guilherme Costa
...and I am using physical device, already recognized with the command
adb devices– Guilherme Costa
Got...I had to create the project with npx and create local file.properties in android folder, and had not created. By doing this, it worked.
– Guilherme Costa
Do an answer in the field below (bottom of the page). It’s okay to answer your own question and accept your answer as a solution, you don’t have to ask
[Resolvido]in the title of the question :)– Rafael Tavares