1

I built a normal android app which uses Firebase to store data(name,email and number) and it runs perfectly but i have a dependency conflict error which i am unable to solve. the message which i get "Message Gradle Build" is: Error:Execution failed for task ':app:preDebugAndroidTestBuild'.

Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.2.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

and my build.gradle file contains:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.arya.anish.myfirebaseexample"
        minSdkVersion 19
        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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}


apply plugin: 'com.google.gms.google-services'

how to overcome this error?

string.Empty
  • 10,393
  • 4
  • 39
  • 67
Anish Arya
  • 518
  • 1
  • 7
  • 24

2 Answers2

0

try adding this to your app level .gradle file

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1') {
    exclude group: 'com.android.support', module: 'support-annotations'
    }
}
vikas kumar
  • 10,447
  • 2
  • 46
  • 52
  • still the same error. thanks for the help by the way – Anish Arya Jan 09 '18 at 18:53
  • try again with this change – vikas kumar Jan 09 '18 at 18:53
  • I expected this would work. Details on the issue here: https://stackoverflow.com/q/28999124/4815718. Maybe you need to do a Clean before rebuilding. – Bob Snyder Jan 09 '18 at 18:54
  • have a look here also https://stackoverflow.com/questions/40696796/android-how-to-use-espresso-2-2-2-with-support-25-0-0 and https://stackoverflow.com/questions/28999124/resolved-versions-for-app-22-0-0-and-test-app-21-0-3-differ – vikas kumar Jan 09 '18 at 18:59
  • didn't helped much, i added this line " androidTestCompile 'com.android.support:support-annotations:25.4.0' " and finally i figured is that,app version uses 25.2.0 and test app uses 25.4.0 or, if i change it to newer 27.0.2, then it shows test app uses the latest version (i.e, 27.0.2) . is there anyway that i can change the app version i.e, 25.0.2. i tried upgrading firebase to latest version (11.8.0) , but still the error pops up – Anish Arya Jan 09 '18 at 19:36
0

finally figured out how to solve the dependency conflict i added this line in the build.gradle file in the depndencies block:

compile 'com.android.support:support-annotations:27.0.2'

and bingo, no errors now.

Anish Arya
  • 518
  • 1
  • 7
  • 24