1

I am new to android studio and am trying to add Google sheets api v4. On their website it says to add some dependencies to my build.gradle file. Here is what my gradle currently looks like:

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'
}

The error occurs when I try to add the following lines

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'
}

When I try to sync my Gradle I instead get this error:

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.

Any help fixing this would be appreciated as I am pretty new to android studio.

Adrian Avram
  • 887
  • 1
  • 10
  • 14
  • Possible duplicate of [Error:Conflict with dependency 'com.google.code.findbugs:jsr305'](https://stackoverflow.com/questions/37347326/errorconflict-with-dependency-com-google-code-findbugsjsr305) – DeKaNszn Aug 09 '17 at 06:32

1 Answers1

2

In your build.gradle (in app folder) add the following inside android{} body

android {

   ....

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

Related answer: https://stackoverflow.com/a/37357786/8405762

GuilhermeFGL
  • 2,891
  • 3
  • 15
  • 33