'Command Failed: gradlew.bat installDebug error whenever installing dependencies like navigation, firebase, icons etc in React-Native
When ever i install any dependency in my react native project and when ever i use link command for e.g react-native link react-native-gesture-handler this causes me an error shown in the image [1]. It doesn't build the project shows the error gradlew.bat
The following code shows my package.json file
{
"name": "navigations",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-gesture-handler": "^1.0.15",
"react-navigation": "^3.0.9"
},
"devDependencies": {
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
Solution 1:[1]
If you have WINDOWS machine, please follow these steps:
Optional (
Delete iOS, Android folders
Run `react-native eject` ( that command will rebuild deleted folders for you )
)
Then :
1) cd ./android
2) ./gradlew.bat installDebug
( with dot at the beggining )
Once it's successfully finished
3) cd ../
( go back to root folder )
4) react-native run-android
And fingers crossed for it to work as expected :) [for me it does]
Solution 2:[2]
I had the same issue today... Wondering if you solved it?
go to android folder then settings.gradle file
You may find it on line 3
'..\node_modules\react-native-gesture-handler\android'
and replace all these backward slashes with forward like this
'../node_modules/react-native-gesture-handler/android'
Let me know if this helps...
Solution 3:[3]
cd ./android
create file file local.properties
then past this code sdk.dir=C\:\\Users\\muhammad ali\\AppData\\Local\\Android\\Sdk
change location to as per your sdk is located Done.
you already have local.properties file good.
find similar file of code sdk.dir=C\:\\Users\\muhammad ali\\AppData\\Local\\Android\\Sdk
change location to as per your sdk is located Done.
Solution 4:[4]
Make sure you already have installed python 2 and last version of jdk And make sure you have already set ANDROID_HOME
Solution 5:[5]
I got this same issue in when creating splash screen set to the MainActivity.java. Then I downgrade the react native version (0.59.8). I didn't change the gradle version.
Solution 6:[6]
To solve this issue just change the compileSdkVersion in your build.gradle file.
Open android > build.gradle file. Change compileSdkVersion from 29 to 30. Change targetSdkVersion from 29 to 30. now run again.
Solution 7:[7]
I had the same problem and used unusual solution but is helped me. after create your react-native project, open android folder by android studio, it will config your gradle Correctly and then you can run your app on simulator
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Basit |
Solution 3 | Muhammad Ali |
Solution 4 | hamidreza nasrollahy |
Solution 5 | chamila |
Solution 6 | Sumj25 |
Solution 7 | amin |