How to change gradle version to v5.1.1

Hi,
I trying to modify the gradle version in the baseProjectTemplate.gradle by setting it like this:

allprojects {
    buildscript {
        repositories {**ARTIFACTORYREPOSITORY**
            google()
            jcenter()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:5.1.1'
            **BUILD_SCRIPT_DEPS**
        }
    }

    repositories {**ARTIFACTORYREPOSITORY**
        google()
        jcenter()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And as you can see Gradle v5.1.1 is available in my Unity installation folder:

When I build I’m getting this error:

Could not find com.android.tools.build:gradle:5.1.1.

I’m using Unity 2019.4.16f1

Any idea what’s going wrong?

You’re confusing gradle version with Android Gradle Plugin version, those are two different things.

gradle-launcher-5.1.1 <— 5.1.1 is gradle version.
com.android.tools.build:gradle:5.1.1 <— 5.1.1 is Android Gradle Plugin version.

According to this - https://developer.android.com/studio/releases/gradle-plugin?authuser=1#updating-gradle, I am not sure if Android Gradle Plugin 5.1.1 even exist yet. But that table should help you figure out which version you want

2 Likes

Thanks for the explanation, it’s much clear now!