1

同步 gradle 项目时出现此错误。

无法解决依赖关系':app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0

谁能帮我?

apply plugin: 'com.android.application' android {
compileSdkVersion 26
defaultConfig {
    applicationId "com.example.phaniteja.sample1"
    minSdkVersion 15
    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:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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' }
4

2 回答 2

1

Unable to resolve dependency for :app@debugAndroidTest/compileClasspath': Could not resolve com.android.support:design:26.1.0当 Android Studio 无法下载该依赖项时,通常会发生此问题。这可能是由于诸如此类的许多原因,或者 在我的情况下,Maven2jcenter存储库在 Company 中被阻止。所以你能做的就是检查这个文件夹

Android-sdk\extras\android\m2repository\com\android\support\appcompat-v7

并检查 SDK 中哪些所有版本都可供您使用,使用其中任何一个版本,因此不是从存储库下载,而是从 SDK 获取该库。

于 2018-03-19T12:32:18.893 回答
0

尝试添加您的 Google Maven 存储库。这个对我有用。##

repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
于 2018-09-17T12:23:15.403 回答