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.
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.
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.
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.
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:
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.
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.
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With