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

廉价感情. 提交于 2020-12-05 07:23:54

问题


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}"

}

回答1:


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()
    }
}



回答2:


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



来源:https://stackoverflow.com/questions/57027443/gradle-sync-failed-could-not-find-com-android-tools-buildgradle5-5-1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!