无法解析来自 Android 支持存储库的导入(包括 Google 的 Maven)

Unable to resolve imports from Android Support Repository (Google's Maven included)

在 Android Studio 2.3 中:

应用build.gradle:

apply plugin: 'com.android.application'

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.0'
    compile 'com.android.support:support-v4:27.0'
    testCompile 'junit:junit:4.12'
}

root build.gradle:

   buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'

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

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

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

结果是支持库没有解析,尽管我明确添加了 Google maven 存储库:

Error:(27, 13) Failed to resolve: com.android.support:support-v4:27.0 ... Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:27.0 ...

我怀疑你必须添加完整版本代码,例如:

compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-v4:27.0.0'

注意我在版本中添加了最后一个“.0”

根据您的 gradle 版本,您现在需要使用 google()。

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
        google()
    }
}

而不是

maven {
            url 'https://maven.google.com'
        }