Home » Android » Jenkins cannot resolve com.android.tools.build:gradle:3.0.0-alpha8

Jenkins cannot resolve com.android.tools.build:gradle:3.0.0-alpha8

Posted by: admin June 15, 2020 Leave a comment

Questions:

I upgraded to Android studio version 3.0 Canary 8 and followed the auto-prompt on Android studio to upgrade the android gradle plugin version to “3.0.0-alpha8”.

My Jenkins build now fails to resolve “com.android.tools.build:gradle:3.0.0-alpha8.”. Below are the build error logs

Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.0-alpha8.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.pom      
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.jar
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.pom         https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.jar        https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.pom        https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.0-alpha8/gradle-3.0.0-alpha8.jar

My root project build.gradle is as follows:

buildscript {
repositories {
    jcenter()
    google() 
    // maven { url "https://maven.google.com" } does not work as well
    maven { url 'https://maven.fabric.io/public' }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-alpha8'
    classpath 'com.google.gms:google-services:3.1.0'
    classpath 'io.fabric.tools:gradle:1.23.0'
}
}

Same code builds successfully on Android Studio, but fails on Jenkins

How to&Answers:

You must add this url in your repositories root build.gradle:

    maven { url 'https://maven.google.com' }

Like this:

buildscript {

    repositories {
       jcenter()
       mavenCentral() // add repository
       maven { url 'https://maven.google.com' }
     }
}

Regards