【问题标题】:Error with adding dependencies to my build.gradle in android studio (Conflict with dependency)在 android studio 中将依赖项添加到我的 build.gradle 时出错(与依赖项冲突)
【发布时间】:2018-01-16 12:07:26
【问题描述】:

我是 android studio 的新手,正在尝试添加 Google sheet api v4。 On their website 它说要在我的 build.gradle 文件中添加一些依赖项。 这是我的 gradle 目前的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example"
        minSdkVersion 16
        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 {
    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.google.android.gms:play-services-location:11.0.4'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.android.support:design:26.+'

    testCompile 'junit:junit:4.12'
}

当我尝试添加以下行时出现错误

compile('com.google.api-client:google-api-client-android:1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-sheets:v4-rev483-1.22.0') {
    exclude group: 'org.apache.httpcomponents'
}

当我尝试同步我的 Gradle 时,却收到了这个错误:

Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'. Resolved versions for app (1.3.9) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

任何解决此问题的帮助将不胜感激,因为我是 android studio 的新手。

【问题讨论】:

标签: android android-studio dependencies build.gradle google-sheets-api


【解决方案1】:

在您的build.gradle(在应用文件夹中)在android{} 正文中添加以下内容

android {

   ....

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

相关回答:https://stackoverflow.com/a/37357786/8405762

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-19
    • 2015-12-31
    • 2021-11-05
    • 1970-01-01
    • 2018-05-18
    • 2022-01-19
    • 1970-01-01
    • 2016-11-05
    相关资源
    最近更新 更多