【问题标题】:Could not resolve com.android.support:design:26.1.0无法解析 com.android.support:design:26.1.0
【发布时间】:2018-08-15 00:48:00
【问题描述】:

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

这些是我的模块 gradle 文件。

Build.gradle(应用程序)

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。

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

错误:无法解决依赖关系 对于“:app@debugUnitTest/compileClasspath”:无法解析 com.android.support:design:26.1.0。

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

错误:无法解决依赖关系 对于“: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 无法从网站下载某些依赖项,这就是为什么我无法下载更多其他依赖项的原因。 (虽然我的线下工作是不勾选的)

此外,无论上面代码中未注释的内容是什么,这意味着我已尝试输入这些行,但它并没有解决问题,或者反而造成了更多问题。

【问题讨论】:

  • 请更新SDK工具
  • @akshay SDK 工具是最新版本,但我仍然有同样的问题。刚刚也检查了一遍。
  • @akshay 那么你知道我可以尝试的其他任何事情吗?

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


【解决方案1】:

这是我找到它的方式,请尝试以下方式

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

【讨论】:

    【解决方案2】:

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

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

    并删除它

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

    【讨论】:

    • 正如您可能已经看到的那样,我取消了编译“com.android.support:design:26.1.0”的注释,因为它不能正常工作。我应该更清楚地写下我到目前为止所做的事情
    【解决方案3】:

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

    所以通过设置 HTTPS 代理解决了这个问题后,就没有更多问题了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      相关资源
      最近更新 更多