首页 > 解决方案 > 为什么android studio在我添加依赖项时会出错?

问题描述

我正在构建一个人脸检测 Android 应用程序。当我在其中添加依赖项时,app/build.gradle它会给我一个错误。这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.android.emojify"
        minSdkVersion 15
        targetSdkVersion 28
        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'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support ', module: 'support-annotations'
    })
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-vision:10.2.0'
    testImplementation 'junit:junit:4.12'
}

错误报告如下:

implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'

标签: javaandroidandroid-studiogradle

解决方案


您的 buildToolVersion 大于您的设计和 appcompat-v7。
尝试改变,

implementation 'com.android.support:design:28.0.3' //or greater than 28.0.3  
implementation 'com.android.support:appcompat-v7:28.0.3' //or greater than 28.0.3  

连接到互联网,然后构建您的项目。问题将得到解决。


推荐阅读