How to change gradle version in Android Studio with ejected Expo app

How to change gradle version in Android Studio with ejected Expo app

TLDR: set the distributionUrl in android\gradle\wrapper\gradle-wrapper.properties  correctly

I am using expo to build our app Pocketcoach (https://www.pocketcoach.co)

A new feature needed us to eject from expo. The process is pretty straight forward you can check in their documentation here https://docs.expo.io/versions/v35.0.0/bare/customizing/

However when I tried to build our app for android, I encountered a strange error:

"Cannot add task 'wrapper' as a task with that name already exists"

After a bit of googling I discovered that this is likely due to expo using gradle 4.7 at the moment (SDK 35)

You can check this by looking at the build.gradle script for the project in android\build.gradle und wrapper where it says: gradleVersion = '4.7'

In order to fix your error you need to go to android\gradle\wrapper\gradle-wrapper.properties and set the distributionUrl to the correct version, you can find it here:

https://gradle.org/releases/

Hope this helps someone