After creating a new project in Android Studio, I added Firebase and Firebase-messaging to the project, as described in the manual.
However, after Gradle sync, the IDE displays an error:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-beta01, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-beta01 and com.android.support:support-media-compat:26.1.0
Without Firebase libraries, the project is built correctly.
Project-level build.gradle
:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module-level build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ru.sabernyan.myapplication"
minSdkVersion 16
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'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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.android.support:design:28.0.0-beta01'
}
apply plugin: 'com.google.gms.google-services'
The rest of the files were not changed.
Versions:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.17.11-zen1
Using
gradle app:dependencies
, I got a list of dependencies:It shows that Firebase pulls the dependency
com.android.support:support-v4:26.1.0
, so I overwritten it, and my build.gradle now looks like this:And it worked!
Adding any libraries listed in the error message gets rid of the message. (You have to check the error message again after adding each library). For me, I had to add two libraries:
I'd still like to know, though, why Firebase is using these old libraries and why a simple fix like this works if Firebase actually needs those old libraries.
add this in dependencies
I add this 2 lines and solved my problem:
implementation 'com.android.support:support-media-compat:28.0.0-beta01'
implementation 'com.android.support:support-v4:28.0.0-beta01'