How can I upgrade react-native gradle version

2020-06-01 07:20发布

问题:

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.

回答1:

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



回答2:

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.