Gradle同步失败:找不到com.android.tools.build:gradle:5.5.1 [英] Gradle sync failed: Could not find com.android.tools.build:gradle:5.5.1

查看:209
本文介绍了Gradle同步失败:找不到com.android.tools.build:gradle:5.5.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我遇到了一个奇怪的问题.我想将我的gradle从版本2.14.1升级到5.5.1,它不会让我使用.

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.

这是我得到的错误:

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.

这是我的build.gradle文件的外观:

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

我还仔细检查了Android Studio > Properties > Gradle > Use local Gradle distribution中的gradle路径,并将其设置为根gradle-5.5.1目录.

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) 

我做错了什么?

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

}

推荐答案

此依赖项对应于 Android gradle插件,而不是Gradle本身.通常,Android gradle插件应与您的Android Studio安装的版本号匹配(例如"3.4.2").

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").

如果要更新Gradle本身,并且正在使用gradle包装器,请更新gradle/wrapper/gradle-wrapper.properties文件并编辑distributionUrl行:

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

如果您使用的是本地发行版,则无需执行任何操作.您的项目将使用Android Studio设置(在您的情况下为Gradle 5.5.1)中设置的gradle分布构建.

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).

看来您的build.gradle文件也缺少google()存储库,如果您要使用Android gradle插件3.4.2,它应该是这样:

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

这篇关于Gradle同步失败:找不到com.android.tools.build:gradle:5.5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆