Command Failed: gradlew.bat installDebug error whenever installing dependencies like navigation, firebase, icons etc in React-Native
Asked Answered
O

10

22

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"
  }
}
Opalopalesce answered 29/1, 2019 at 6:48 Comment(2)
Apparently your settings.gradle file got corrupted. What is its content after the link command?Sherrill
Yes this happened after the linked commandOpalopalesce
H
43

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]

Heehaw answered 15/2, 2019 at 10:20 Comment(6)
In windows ./ does not work. Omit the ./ to run gradlew.bat installDebug Had the same issue. This one worked for me.Programmer
Optional ( Delete iOS, Android folders Run react-native eject ( that command will rebuild deleted folders for you ) ) where did you get this?Bearden
Poorly described. The command in number 2 does not workGreyhen
what about mac?Tableware
You have to add quotes "./gradlew.bat" installDebugExtroversion
my issue was related to java-sdk version, which I changed to 8 and everything works fine.Tableware
P
3

Here is how I resolved this problem.

Step 1: Open Android Studio -> File -> Invalided caches.. [ select all -> click Invalidated and Restart]

Android Studio -> File -> Invalided caches

Step 2: Open device manager -> select device -> use Wipe data and cold boot now

use Wipe data and cold boot now

Step 3: run npx react-native run-android in power shell

If not build successfully. Then use the following step.

Step 3.1: Open 2 PowerShell command plates then

  1. start metro bundler: npx react-native start --reset-cache --port 8084
  2. run-android : npx react-native run-android

Or If still not built successfully. Then try following step.

Step 4: Create another device with a supported API level. I used API 33 -> R 30 (API lavel). Now use Step 3.

Enjoy and Happy Coding...

Peerless answered 13/9, 2022 at 11:49 Comment(0)
T
2
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.

Thoughtful answered 31/3, 2021 at 8:21 Comment(1)
C:\Users\ashad\AppData\Local\Android\Sdk sdk.dir=C\:\\Users\\ashad\\AppData\\Local\\Android\\SdkIncurvate
F
1

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...

Fleabag answered 3/2, 2019 at 16:44 Comment(2)
Yes this helped I replaced all the "\" with "/" and cleaned the gradlew by command gradlew clean and the code run fineOpalopalesce
@OvaisButt thanks for reminding me to gradlew clean. I forgot to do that after running gradlew.bat installDebugDispassion
J
0

Make sure you already have installed python 2 and last version of jdk And make sure you have already set ANDROID_HOME

Janycejanyte answered 6/2, 2019 at 4:15 Comment(0)
F
0

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.

Fayfayal answered 10/7, 2019 at 15:52 Comment(0)
D
0

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.

/if this not working then checkout this link

Donela answered 21/7, 2021 at 14:21 Comment(0)
N
0

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

Nonplus answered 19/4, 2022 at 12:36 Comment(0)
A
0

Sometimes this error is caused by the debug keystore at least in my case that was the issue.

What I Did:

I ran this command to generate a new debug keystore

Windows Users:

keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

MAC / Linux Users:

$ keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

Answer the prompt questions.

When the keystore is generated successfully go to android/app and place the keystore file there while updating your android/app/build.gradle file with:


  signingConfigs {
        debug {
            storeFile file('the-keystore-name.keystore')
            storePassword 'the-keystore-prompt-password'
            keyAlias 'the-keystore-alise-name'
            keyPassword 'the-keystore-promtp-password'
        }

    }

Thanks it! Just run yarn android again it should build now.

GOOD LUCK!

Axletree answered 5/1, 2023 at 11:37 Comment(0)
H
-1

I went into android studio and edited my emulated devices' storage capacity (RAM, VM heap, Internal Storage, removed SD card) in advanced settings. I believe I bumped every setting up. Virtual Device settings I'm not sure if this will solve your issue, however, it did resolve mine.

After that, I recreated a new project (npx react-native ...) then it worked like a charm.

As far as my computer goes, it has plenty of storage and ram so I wasn't too concerned with those limitations. Good luck

API = 33
Android Studio Version = 2021.2

H answered 13/9, 2022 at 18:7 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Lachrymator

© 2022 - 2024 — McMap. All rights reserved.