Android:错误:找不到com.android.support:appcompat-v7:28.0.0

时间:2018-10-21 18:47:01

标签: android gradle

当您执行所有Android Studio建议的操作而仍然因执行不足而仍然出错时,这令人沮丧。我正在重新访问一个项目并在Android Studio 3.3 beta 1上运行。应用建议的更新后,应用程序gradle文件如下所示:

    apply plugin:'com.android.application' 
android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3' 
    defaultConfig { 
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    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:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'com.github.bumptech.glide:glide:4.4.0'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation "com.google.android.gms:play-services-gcm:16.0.0"
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.google.android.gms:play-services-places:16.0.0'
    testImplementation 'junit:junit:4.12'

    implementation 'com.google.android.apps.muzei:muzei-api:2.0'
} 
apply plugin: 'com.google.gms.google-services'

enter image description here

当我进入SDK Manager时,一切都已安装:

enter image description here

在gradle.build中:

    buildscript {
    repositories {
        jcenter()
        google()
    } 
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0-alpha01'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.3.0'
    }
}

我该怎么办?任何建议表示赞赏。

1 个答案:

答案 0 :(得分:3)

您缺少顶级build.gradle文件的一部分。它应该类似于:

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

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

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

尤其是,您缺少allprojects闭包,该闭包为每个模块中的依赖项解析设置了存储库。结果,模块的build.gradle文件不知道在哪里寻找那些依赖项。