无法解决':app @ debug / compileClasspath'的依赖关系

时间:2018-07-22 17:38:13

标签: android android-studio gradle android-gradle

我有一个使用android studio 2.3开发的android项目,之后我将android studio更新为3.3,并使用新版本打开了该项目,但遇到了很多错误,但解决了很多错误但又有新错误 这是我的应用程序build.gradle:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 26
        buildToolsVersion "27.0.3"
        defaultConfig {
            applicationId ""
            minSdkVersion 16
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            aaptOptions {
                cruncherEnabled = false
            }
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })

        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support:design:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:cardview-v7:26.1.0'
        implementation 'com.android.support:recyclerview-v7:26.1.0'
        implementation 'com.squareup.picasso:picasso:2.5.2'
        implementation 'com.jakewharton:butterknife:8.8.1'
        implementation 'com.roughike:bottom-bar:2.0.2'
        implementation 'com.android.support:palette-v7:26.1.0'
        implementation 'com.android.support:support-v4:26.1.0'
        implementation 'com.google.android.exoplayer:exoplayer:r2.3.1'
        testImplementation 'junit:junit:4.12'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
        implementation 'com.android.support:support-core-utils:26.1.0'
    }

这是我的项目build.gradle:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha02'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}

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

这是我的gradle-wrapper-properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip

这是我得到的错误:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:26.1.0.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:cardview-v7:26.1.0.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:recyclerview-v7:26.1.0.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.roughike:bottom-bar:2.0.2.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:palette-v7:26.1.0.
Open File
Show Details

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:support-v4:26.1.0.
Open File
Show Details

............等等

我正在尝试将所有依赖项的26.0.1和目标sdk从26更改为27和27.1.1,并且得到了相同的错误

我已经使用代理了,所以这是我的gradle.properties:

systemProp.http.proxyHost=ip
systemProp.http.proxyPort=port
systemProp.http.proxyUser=user
systemProp.http.proxyPassword=pass

systemProp.https.proxyHost=ip
systemProp.https.proxyPort=port
systemProp.https.proxyUser=user
systemProp.https.proxyPassword=pass

并通过使用手动代理配置从设置> HTTP代理开始

,当我添加 google()来处理更改为的错误时:

Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not determine artifacts for com.android.support:support-core-utils:27.1.1
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/support-core-utils/27.1.1/support-core-utils-27.1.1.aar'.
Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/support-core-utils/27.1.1/support-core-utils-27.1.1.aar'. Received status code 407 from server: Proxy Authentication Required

所以我只删除google() 有什么问题吗?

1 个答案:

答案 0 :(得分:1)

您尚未在根 build.gradle 中包含google()存储库。

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha02'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}



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