1

Today I started a new project in android studio. Everything went good and there was no error. After Adding the project, I connected the project with Firebase Real-time Database with the help of Firebase assistant tool in android studio.

Then I get this error:

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

enter image description here

I see that the error mainly comes from adding this line at the end of my app level build.gradle file. Because when I comment it out, it builds fine.

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

I don't know much about gradle building system. What could be wrong with only connecting to firebase and adding the firebase-database dependencies.

Resources that me need inspection

My app:build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.learning.insanes.chothavandar"
        minSdkVersion 21
        targetSdkVersion 27
        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.6.0'
    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'

My project:build.gradle :

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Rahat Zaman
  • 1,322
  • 14
  • 32

2 Answers2

2

Try this:

 androidTestCompile ("com.android.support.test.espresso:espresso-core:3.0.1") {
      exclude group: 'com.android.support', module: 'support-annotations'
 }

Look at this link for better understanding

Roberto Martucci
  • 1,237
  • 1
  • 13
  • 21
  • Please elaborate your answer. Where should I put this? What actually is my problem and how will it help to resolve my problem? – Rahat Zaman Nov 30 '17 at 23:59
  • In your app build.gradle there is this line of code `androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'`. Replace it with the one I posted. It will exclude the library module reported. You have this error because you're trying to compile two different versions of the same library. Read the link I suggested to understand better your problem – Roberto Martucci Dec 01 '17 at 00:06
  • Thanks. Your solution works. If you have also `test:runner` as a test dependency remember to add: `androidTestImplementation ("com.android.support.test:runner:1.0.1") { exclude group: 'com.android.support', module: 'support-annotations' } ` – kosiara - Bartosz Kosarzycki Mar 16 '18 at 10:16
-1

In your app: build.gradle file in dependencies add the following lines or if already there change it as:

dependencies { .. implementation 'com.android.support:appcompat-v7:25.4.0' .. }