Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upgrade react-native gradle version

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.

like image 430
Siberhecy Avatar asked Jul 23 '18 13:07

Siberhecy


People also ask

Does react native use Gradle?

When you install pure react-native app, (i.e not expo) , it comes with 2 directories, one android and the other ios respectively. So react native uses Gradle for building automation purposes , like generating signed or unsigned APK from the terminal itself.

How do I update my react native app?

Because typical React Native projects are essentially made up of an Android project, an iOS project, and a JavaScript project, upgrading can be rather tricky. There's currently two ways for upgrading your React Native project: by using React Native CLI or manually with Upgrade Helper.

How to upgrade a React Native App?

Upgrading a React Native app by creating a new project. The second, the oldest and the best way, for now, is creating a new project in the latest react native version. After that, you should move all the files from the old repo to the one you have just created.

How do I install pods in React Native?

Assuming you are in your new react native project, you should go to the iOS project first (cd ios) and then install pods. After running this command you should get a result similar to:

How do I upgrade a Gradle build?

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.

Why does my React Native project keep crashing?

These sort of errors are usually related to caching, it's recommended to install react-native-clean-project to clear all your project's cache and then you can run it again.


3 Answers

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

like image 88
Daniel Gabor Avatar answered Oct 14 '22 04:10

Daniel Gabor


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.

like image 10
justinhook Avatar answered Oct 14 '22 04:10

justinhook


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.

like image 4
Dinesh Verma Avatar answered Oct 14 '22 05:10

Dinesh Verma