21
votes

I need help. I can't upgrade gradle version of my react-native project.

I try a lot of things, downloaded last version of Android Studio & SDK Tools etc.

I changed this file \android\gradle\wrapper\gradle-wrapper.properties, I tried to upgrade using npm install -g react-native-git-upgrade but still I can't upgrade it.

When I react-native eject It's exports "distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip"

Waiting for answers.

5

5 Answers

35
votes

In android/build.gradle you have to edit this line

classpath 'com.android.tools.build:gradle:x.y.z'

Change x.y.z with the version you want. Edit it with Android Studio then click Sync now

4
votes

In {yourProject}\android\gradle\wrapper\gradle-wrapper.properties, update:

distributionUrl=https\://services.gradle.org/distributions/gradle-{your version}.zip

Find your version of gradle with

gradle --version

You may need to install gradle wrapper if you haven't already.

2
votes

you can go to https://services.gradle.org/distributions/ and check that latest -all.zip version of gradle and update the same in your gradle-wrapper.properties file. When you run your react-native app the next time, your gradle will first get upgraded and then run.

0
votes

From Gradle's site:

https://gradle.org/install/#with-the-gradle-wrapper

Upgrade with the Gradle Wrapper If your existing Gradle-based build uses the Gradle Wrapper, you can easily upgrade by running the wrapper task, specifying the desired Gradle version:

$ ./gradlew wrapper --gradle-version=6.6.1 --distribution-type=bin Note that it is not necessary for Gradle to be installed to use the Gradle wrapper. The next invocation of gradlew or gradlew.bat will download and cache the specified version of Gradle.

$ ./gradlew tasks Downloading https://services.gradle.org/distributions/gradle-6.6.1-bin.zip ...

Run these commands in your project's android folder

0
votes

For react native Go to File -> Project Structure -> Change gradle version to 6.1.1 plugin version to 4.0.0 Try different combinations Use this link - https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle