I'm starting to learn develop android apps.
I'm following a firebase tutorial, and I'm getting some errors on my build.gradle
file.
Can someone please help me?
My build.gradle
file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "br.com.brunots.firebasetests"
minSdkVersion 16
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 ''
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:11.8.0'
testImplementation 'junit:junit:4.1com.android.support:appcompat-v7:27.1.02'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:design:27.1.0'
compile 'com.firebaseui:firebase-ui:0.6.0'
}
apply plugin: 'com.google.gms.google-services'
These are the errors:
- All gms/firebase libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 9.6.0, 11.8.0. Examples include
com.google.android.gms:play-services-auth:9.6.0
and
com.google.android.gms:play-services-basement:11.8.0
- All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.1.0, 23.4.0. Examples include
com.android.support:animated-vector-drawable:27.1.0
and
com.android.support:cardview-v7:23.4.0
I don't know where is this the older versions is declared.
This is because you're using firebase-ui version 0.6.0 which is implicitly using firebase and google play service version 9.6.0 (read more about it at https://github.com/firebase/FirebaseUI-Android/releases/tag/0.6.0). So, you can't use the following:
implementation 'com.google.firebase:firebase-core:11.8.0'
compile 'com.firebaseui:firebase-ui:0.6.0'
you need to use firebase-ui version 3.2.2 which is using firebase 11.8.0 ( read more at https://github.com/firebase/FirebaseUI-Android) like this:
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.firebaseui:firebase-ui:3.2.2'
and you also need to use support library version 27.0.2 for firebase-ui 3.2.2 (look at https://github.com/firebase/FirebaseUI-Android/blob/master/constants.gradle)
Use classpath 'com.google.gms:google-services:3.2.0' // google-services plugin
in your build.gradle(project), then in build.gradle(app) add following firebase dependencies:
dependencies {
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.firebaseui:firebase-ui:11.8.0'}
because when you are using firebase, all its dependencies version must be same.
And for the second error, share what you want to achieve, as it is because of version differences.
Add this to the very end of your build.gradle (Module:app):
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
Android library versions are supposed to use the same version as your buildToolsVersion which you do not have included. For SDK 27 you should be using 27.0.3. So the android section should start with:
compileSdkVersion 27
buildToolsVersion "27.0.3"
and the included libraries should end with
:27.0.3
I solved that analising the dependency tree:
gradlew app:dependencies
so I saw that conflicts are transitive dependencies of com.firebaseui:firebase-ui-auth:0.6.0
then i use exclude on my build.glade:
compile ('com.firebaseui:firebase-ui:0.6.0') {
exclude group: 'com.android.support'
exclude group: 'com.google.firebase'
exclude group: 'com.google.android.gms'
}
No more mixing versions :D
configurations.all {
resolutionStrategy {
implementation 'com.android.support:design:27.1.0'
}
}