3

This is app level dependency.I have been trying to add firebase to my app.but it shows an error

apply plugin: 'com.android.application'  

    android {  
        compileSdkVersion 28  
        defaultConfig {  
            applicationId "com.example.rachitshah.fireapp"  
            minSdkVersion 15  
            targetSdkVersion 28  
            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'])  

error in this line

 implementation 'com.android.support:appcompat-v7:28.0.0'  
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'  
        testImplementation 'junit:junit:4.12'  
        androidTestImplementation 'com.android.support.test:runner:1.0.2'  
        androidTestImplementation   'com.android.support.test.espresso:espresso-core:3.0.2'  

this is firebase dependency.

implementation 'com.google.firebase:firebase-core:16.0.1'  
Ajeett
  • 814
  • 2
  • 7
  • 18
  • take look to this link : https://stackoverflow.com/questions/42374151/all-com-android-support-libraries-must-use-the-exact-same-version-specification – mohammadReza Abiri Feb 24 '19 at 12:51

2 Answers2

1

When you add firebase dependency in gradle file by adding

implementation 'com.google.firebase:firebase-core:16.0.1'

Then there are 2 libraries have been added in your app as well

com.android.support:support-media-compat:26.1.0
com.android.support:support-v4:26.1.0

Their versions are different from versin 28.0.0 that why the error occurs.

To fix this error, change your gradle file

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'

    // Add this line
    implementation 'com.android.support:support-v4:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
}
Son Truong
  • 13,661
  • 5
  • 32
  • 58
0

check out this post android manifest merger failed, gms play services / firebase

You probably imported a library that does not use the specified version 28. So either remove the specification or make sure they are all on the same version

fogx
  • 1,749
  • 2
  • 16
  • 38