Reputation: 621
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.
Upvotes: 44
Views: 162978
Reputation: 1
Check Gradle Releases: Visit the Gradle releases page (https://services.gradle.org/distributions/) to find a compatible version. Ideally, choose a stable release and avoid RC (release candidate) versions. Opt for versions ending in -all.zip.
Update gradle-wrapper.properties: Open the gradle-wrapper.properties file and edit the distributionUrl property. Replace the existing URL with the one you obtained from the Gradle releases page for your desired version (e.g., distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-bin/gradle-7.5.1-all.zip).
Update Gradle: Run the following command in your project's root directory (replace 7.5.1 with the actual version you chose):
./gradlew wrapper --gradle-version=7.5.1
Upvotes: 0
Reputation: 1
you can directly update gradle version which you want,
for example
I hope it's work for you guys
Upvotes: 0
Reputation: 857
Open Android Studio and navigate to File → Project Structure
Then click on the Project option.
then choose the latest version of Gradle. After that click on Ok.
Upvotes: 4
Reputation: 2640
I had opened my project in Terminal and ran open -a /Applications/Android\ Studio.app
to open Android Studio but so that it can access node to download my gradle version which it did automatically.
Learned from this original post: React Native on Android: Cannot run program "node": error=2, No such file or directory
Upvotes: 1
Reputation: 335
There are two things
Android Gradle Plugin
You can see the version of it in android/build.gradle file and update it using Daniel's answer here
Gradle version
You can see this in android\gradle\wrapper\gradle-wrapper.properties file and update it using the answer mentioned here
To know the difference between them refer following links:
https://developer.android.com/studio/releases/gradle-plugin
difference between android gradle plugin and gradle
Upvotes: 6
Reputation: 313
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
Upvotes: 0
Reputation: 666
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.
Upvotes: 11
Reputation: 90
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
Upvotes: 3
Reputation: 134
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.
Upvotes: 13
Reputation: 1526
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
Upvotes: 62