无法解决com.android.support:design:26.1.0

时间:2018-03-07 02:19:32

标签: android-gradle build.gradle android-design-library android-snackbar android-support-design

我一直有这个问题已经有一段时间了,我的com.android.support:design:26.1.0让我失望了,我不知道该改变什么了。

这些是我的模块gradle文件。

  

Build.gradle(app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.google.android.gms:play-services-vision:9.4.0'
//    compile 'com.android.support:design:26.1.0'
}

//apply plugin: 'com.google.gms.google-services'
  

项目gradle文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter({ url "http://jcenter.bintray.com/" })
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
//        classpath 'com.google.gms:google-services:3.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

错误:无法解析依赖关系   ':app @ releaseUnitTest / compileClasspath':无法解决   com.android.support:design:26.1.0。

     

错误:无法解析依赖关系   for':app @ release / compileClasspath':无法解决   com.android.support:design:26.1.0。

     

错误:无法解析依赖关系   for':app @ debugUnitTest / compileClasspath':无法解析   com.android.support:design:26.1.0。

     

错误:无法解析依赖关系   for':app @ debugAndroidTest / compileClasspath':无法解决   com.android.support:design:26.1.0。

     

错误:无法解析依赖关系   for':app @ debug / compileClasspath':无法解决   com.android.support:design:26.1.0。

只有'Snackbar'功能不起作用,但其余部分似乎没问题。

当我将设计更改为25.1.0版本时,它可以正常工作,但它与其他26.1.0版本冲突,因此不会被Android Studio推荐。任何人..?

我试过把

compile 'com.android.support:design:26.1.0'

而不是实现,它不起作用。当我试图将整个事物更改为25.4.0或任何其他25版本时,许多其他事情也不会编译。我已经取消选中了脱机工作,尝试删除/添加maven目录,取消注释一些依赖项,将所有更改为编译而不是实现,但只是给了我更多错误。

是的我已将所有SDK更新到最新版本,但我感觉Gradle无法从网站下载某些依赖项,这就是为什么我无法再下载任何其他依赖项的原因。 (虽然我的离线工作未经检查)

此外,无论在上面的代码中没有注释,这意味着我已经尝试输入这些行,但它没有解决问题,或者更多的问题。

3 个答案:

答案 0 :(得分:0)

以下是我找到它的方法,请尝试下面的

Go to File->Settings->Build, Execution, Deployment->Gradle->Uncheck Offline work option.

答案 1 :(得分:0)

尝试一次,而不是实现编译设计支持gradle代码

compile 'com.android.support:design:26.1.0'

并删除此

 implementation 'com.android.support:design:26.1.0'

答案 2 :(得分:0)

我最终意识到的问题是,当我设置android代理时,我只设置了1个用于HTTP的代理,并没有意识到没有设置HTTPS代理。

因此,在通过设置HTTPS代理修复该问题之后,就没有其他问题了。