"com.android.support:appcompat-v7:28.0.0" Error

Whenever i add firebase database dependency it shows appcompat error. Like this

"All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0"

   dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support.constraint:constraint- 
        layout:1.1.3'
        implementation 'com.google.firebase:firebase-database:16.1.0'
        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'
   }

"All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0"

Solution: Adding com.android.support:support-v4:28.0.0 dependency into your gradle file.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint- 
    layout:1.1.3'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    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'

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

Add the dependency implementation 'com.android.support:support-v4:28.0.0' along with implementation 'com.android.support:appcompat-v7:28.0.0'

Also stable release of Support Library 28.0.0 and is the last feature release under the android.support packaging, and developers are encouraged to migrate to AndroidX

  android {
  compileSdkVersion 28
  buildToolsVersion "28.0.3"


 defaultConfig {
 applicationId "com.your_project_name"
 minSdkVersion 23
 targetSdkVersion 28
 versionCode 1
 multiDexEnabled true
 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

 dependencies {
 implementation fileTree(dir: 'libs', include: ['*.jar'])
 implementation 'com.android.support:appcompat-v7:28.0.0'
 implementation 'com.android.support:support-v4:28.0.0'
 implementation 'com.android.support:design:28.0.0'
 implementation 'com.android.support:cardview-v7:28.0.0'
 implementation 'com.android.support:recyclerview-v7:28.0.0'
 implementation 'com.android.support.constraint:constraint- 
    layout:1.1.3'
 implementation 'com.google.firebase:firebase-database:16.1.0'
 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.crashlytics.sdk.android:crashlytics:2.9.5' 
 }

implementation 'com.android.support:support-media-compat:28.0.0'

implementation 'com.android.support:support-v4:28.0.0'

add to dependencies and change

implementation 'com.google.firebase:firebase-database:16.1.0'

to

implementation 'com.google.firebase:firebase-database:9.0.2'

This is working for me

Comments
  • what is gradle targeted version code and name ?
  • post your app level and project level gradle because i tried your dependency and its working fine
  • also com.android.support:support-media-compat:26.1.0 also this version 28.0.0
  • compileSdkVersion 28 defaultConfig { applicationId "com.example.uemultancampus" minSdkVersion 23 targetSdkVersion 28
  • thanks for response but i giving error here.