On an empty project, after adding firebase it leads to the following error:
Image Version :-
Text Version :-
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.2.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:support-media-compat:25.2.0
Another error :
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
Is there any possible solution to remove those warnings?
My project build.gradle is:
// 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.1.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
}
My app build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.mad.android.firebasetestauth2"
minSdkVersion 24
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:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth: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'
The error occurs because google-services is implementing some libraries, which are not using the 27.1.1 version. So we need to override the version.
In order to do so, always try to do run this in the terminal of android studio:
./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
This will show you a list of dependencies, which shows the version number along it, something like this :-
Here we need to find those dependencies whose haven't been overwritten and have a version number like 25 or 26 and not overwritten to 27.
Like in the above example we have com.android.support:support-v4:25.2.0
Now we just need to add this to the dependencies block with the up to date version number.
Finally, the dependency block looks like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:12.0.1'
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'
}
Here we are adding
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
To fix the second error of
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
In project build.gradle, update the
classpath 'com.google.gms:google-services:3.1.1'
to
classpath 'com.google.gms:google-services:3.2.0'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With