Android build.gradle error

Hello There!
I am building an android app which connects to my particle photon and makes a pin high or low using a toggle button in my app. I checked the reference guide and got the command statement to add to app:build.gradle
compile 'io.particle:cloudsdk:0.4.6'
When I put this statement to my build.gradle file and tried to sync it, I got this error message
Error:Conflict with dependency 'com.google.code.findbugs:jsr305' in project ':app'. Resolved versions for app (3.0.1) and test app (2.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Can please anyone guide me what I am supposed to do remove this error?
Thanks!

I forget what I had to change to get rid of that error. It was either the SDK version or editing the androidTestCompile line. In any case, here’s a build.gradle file for a test project that builds properly:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.rickk.tempmon10"
        minSdkVersion 15
        targetSdkVersion 24
        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.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'io.particle:devicesetup:0.4.6'
    androidTestCompile 'io.particle:devicesetup:0.4.6'
}
1 Like

Hi @rickkas7
I tried your suggestion but now I am getting multiple errors:

    Preformatted textError:Conflict with dependency 'com.android.support:support-vector-drawable' in project :app. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:appcompat-v7' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-fragment' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-compat' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-media-compat' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:animated-vector-drawable' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-core-ui' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
    Error:Conflict with dependency 'com.android.support:support-core-utils' in project ':app'. Resolved versions for app (26.0.0-alpha1) and test app (25.3.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

And here is my app:build.gradle file,

    apply plugin: 'com.android.application'

    android {
        compileSdkVersion 26
        buildToolsVersion "26.0.0"
        defaultConfig {
            applicationId "com.a09gmail.a23.adityaprakash.particleswitch"
            minSdkVersion 15
            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.android.support:appcompat-v7:26.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'
        compile 'io.particle:devicesetup:0.4.6'
        androidTestCompile 'io.particle:devicesetup:0.4.6'
    }

Please advise me what should I should do to solve this problem.
Thanks!

Try this (removing duplicate findbugs dependency):

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'
        exclude group: 'com.google.code.findbugs', module: 'jsr305'
    })
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'io.particle:cloudsdk:0.4.6'
    //if you need setup sdk
    compile 'io.particle:devicesetup:0.4.7'
}
1 Like