Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync failed: Could not find com.android.tools.build:gradle:5.5.1

Tags:

android

gradle

So, I'm running into an odd issue. I want to upgrade my gradle from version 2.14.1 to 5.5.1 and it won't let me.

Here's the error I get:

Gradle sync failed: Could not find com.android.tools.build:gradle:5.5.1.
            Searched in the following locations:
            - https://jcenter.bintray.com/com/android/tools/build/gradle/5.5.1/gradle-5.5.1.pom
            - https://jcenter.bintray.com/com/android/tools/build/gradle/5.5.1/gradle-5.5.1.jar
            Required by:
            project :
            Consult IDE log for more details (Help | Show Log) (1 s 664 ms)

I was looking through some older posts and they all detail what it was required by and project but oddly, it's blank above.

Here's how my build.gradle file looks like:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:5.5.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

I also double checked the gradle path in Android Studio > Properties > Gradle > Use local Gradle distribution and I have it set to the root gradle-5.5.1 directory.

The log isn't helpful either, it says the same thing as above:

2019-07-14 08:28:28,670 [thread 268]   INFO - e.project.sync.GradleSyncState - Gradle sync failed: Could not find com.android.tools.build:gradle:5.5.1.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/5.5.1/gradle-5.5.1.pom
  - https://jcenter.bintray.com/com/android/tools/build/gradle/5.5.1/gradle-5.5.1.jar
Required by:
    project :

Consult IDE log for more details (Help | Show Log) (5 s 536 ms) 

What am I doing wrong?

EDIT: App > build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'


    signingConfigs {
        liveConfig
                {
                   //removed due to privacy 
                }

        devConfig
                {
                 //removed due to privacy
                }

    }


    defaultConfig {
        applicationId "com.company.name"
        minSdkVersion 19
        targetSdkVersion 28
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.liveConfig
            buildConfigField "boolean", "IS_SERVICES_LIVE", "true"
            //no app created for flurry live tagging
            buildConfigField "boolean", "IS_FLURRY_LIVE", "true"
            buildConfigField "boolean", "IS_FLURRY_QA", "false"
            buildConfigField "String", "BASE_URL", "\"http://media.company.com/WebServices/prod/mobileapps/cc/data/\""

        }

        debug {
            signingConfig signingConfigs.devConfig
            buildConfigField "boolean", "IS_SERVICES_LIVE", "true"
            //no app created for flurry live tagging
            buildConfigField "boolean", "IS_FLURRY_LIVE", "false"
            buildConfigField "boolean", "IS_FLURRY_QA", "false"
            buildConfigField "String", "BASE_URL", "\"http://media.company.com/WebServices/prod/mobileapps/cc/data/\""

        }

    }
    aaptOptions {
        cruncherEnabled = false
    }
    dataBinding{
        enabled true;
    }
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation 'com.android.support:support-v4:28.0.0'

    implementation files('libs/android-binding-v0.6-preview.jar')
    implementation 'com.flurry.android:analytics:8.2.0@aar'
    implementation files('libs/ormlite-android-5.0.jar')
    implementation files('libs/ormlite-core-5.0.jar')
    implementation 'com.google.android.gms:play-services-vision:18.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'io.reactivex:rxjava:1.1.5'
    implementation 'io.reactivex:rxandroid:1.1.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.github.bumptech.glide:glide:4.0.0'

    def appCenterSdkVersion = '2.0.0'
    implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"

}
like image 515
Euridice01 Avatar asked Jul 14 '19 12:07

Euridice01


4 Answers

This dependency corresponds to the Android gradle plugin, not Gradle itself. Typically, the Android gradle plugin should match the version number of your Android Studio installation (e.g. "3.4.2").

If you want to update Gradle itself, and you are using the gradle wrapper, update the gradle/wrapper/gradle-wrapper.properties file and edit the distributionUrl line:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip

If you are using a local distribution, then you don't have to do anything. Your project will be built using the gradle distribution set in the Android Studio settings (in your case, Gradle 5.5.1).

Edit: It seems that your build.gradle file is also missing the google() repositories, here is what it should look like if you want to use the Android gradle plugin 3.4.2:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
like image 91
Dalmas Avatar answered Oct 27 '22 18:10

Dalmas


From mavnrepository.com Google tab, latest stable version:

implementation group: 'com.android.tools.build', name: 'gradle', version: '3.4.2'

Latest alpha:

implementation group: 'com.android.tools.build', name: 'gradle', version: '3.6.0-alpha04'

Note: Only use the Android Gradle Plugin that matches your AS version. For example, you are using AS 3.4.2, so use the Android Gradle Plugin 3.4.2

like image 25
RonTLV Avatar answered Oct 27 '22 18:10

RonTLV


I had same issue with gradle 7.0.2

Adding google() under jcenter() in build.gradle file worked for me

Something like this

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
like image 3
Aaron Avatar answered Oct 27 '22 18:10

Aaron


Go to Android Studio menu, Preferences > Build Execution and Deployment > Build > Gradle and select "'gradle.wrapper.properties' file" in the "Use Gradle From:" menu.

Select your gradle version and plugin version from here:

https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

Set the gradle version in the top build.gradle file.

dependencies {
    classpath 'com.android.tools.build:gradle:4.2.0'
}

Set the plugin version in the gradle.wrapper.properties file, for example:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

Sync Gradle and Build.

like image 1
philburk Avatar answered Oct 27 '22 18:10

philburk