【问题标题】:Why android studio give an error when i add dependency?为什么android studio在我添加依赖项时会出错?
【发布时间】:2018-12-29 06:20:03
【问题描述】:

我正在构建一个人脸检测 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'

【问题讨论】:

  • 什么样的错误?
  • 向我们展示错误日志
  • 尝试使用 implementation 'com.android.support:design:28.0.0-rc01' 并将另一个更改为 implementation 'com.android.support:appcompat-v7:27.0.1'跨度>

标签: java android android-studio gradle


【解决方案1】:

向我们展示您的错误截图或格式化您的错误以便于阅读,只需点击代码按钮并粘贴即可。 编辑:谢谢:)

我认为您应该在 gradle.build 中进行任何更改后使用 refresh gradle,也许您会收到此错误,因为您的构建工具 sdk 是 28.0.3,并且您想使用 sdk 28.0.0 中的工具,只需将 compile sdk 更改为 28.0 .0 并单击操作栏上的同步 gradle。

【讨论】:

    【解决方案2】:

    您的 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  
    

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

    【讨论】:

      猜你喜欢
      • 2016-02-19
      • 2018-01-16
      • 2020-12-08
      • 1970-01-01
      • 1970-01-01
      • 2018-04-25
      • 2014-09-15
      • 1970-01-01
      • 2016-09-11
      相关资源
      最近更新 更多