How to upgrade Android Gradle (for React Native devs)

Luke Rogerson
2 min readDec 13, 2020

--

A boat on a misty Loch Lomand in Scotland
Photo by v2osk on Unsplash

What’s Gradle?

Gradle is a build automation tool for Android applications. It handles things like app compilation, testing and deployment.

Why do I need to upgrade it?

In general, you shouldn’t need to upgrade it explicitly. Newer React Native versions tend to also update the project’s Gradle version, so in most instances you don’t have to worry about it.

Where you might have to upgrade Gradle versions explicitly is in cases where your Android build fails. For example, I had this wonderfully cryptic build error that was only solved by using a newer Gradle version:

> Could not resolve all dependencies for configuration ‘:debug’.
> Problems reading data from Binary store in /tmp/gradle8793563212642185736.bin (exist: false)

OK, so how do I upgrade Gradle?

  1. Check your project’s Gradle version in android/gradle/wrapper/gradle-wrapper.properties. Look for the distributionUrl key.
  2. Go to the Gradle distribution page
  3. Copy the link address of the Gradle version you want update to. I’d suggest you don’t go for the rc ones, and make sure you pick a __-all.zip version.
  4. Paste this copied address to replace the value for distributionUrl. You will need to escape the colon. For example: distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip (notice the \ before the : character)
  5. Run react-native run-android or click “sync” in Android Studio, and your new Gradle version will be downloaded as part of that process!

--

--