Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase has different versions for compile and runtime

started today with Firebase - it seems pretty easy, but currently I'm doing something completely wrong.

My build error:

Error:Execution failed for task ':app:preDebugBuild'. Android dependency 
'com.google.firebase:firebase-core' has different version for the compile 
(9.0.0) and runtime (11.2.0) classpath. You should manually set the same version via DependencyResolution```

with apply plugin: 'com.google.gms.google-services' in the base feature's build.gradle

Without this line there are no build errors, but, Firebase stops working (that was pretty predictable :D)

base feature's build.gradle:

apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'

android {
    baseFeature = true
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 35
        versionName "1.1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
        }
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenCentral()
}

dependencies {
    androidTestCompile('com.android.support.test.espresso:espresso-                core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-    annotations'
    })
    testCompile 'junit:junit:4.12'

    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile "com.android.support:appcompat-v7:$support_version"
    compile "com.android.support:support-v13:$support_version"
    compile "com.android.support:recyclerview-v7:$support_version"

    compile "com.android.support:design:$support_version"
    compile "com.android.support:customtabs:$support_version"
    compile "com.android.support:support-vector-drawable:$support_version"

    implementation "com.google.firebase:firebase-messaging:$firebase_version"
    implementation "com.google.firebase:firebase-database:$firebase_version"
    implementation "com.google.firebase:firebase-appindexing:$firebase_version"
    implementation "com.google.firebase:firebase-core:$firebase_version"

    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}

and the project's one:

buildscript {
    ext.kotlin_version = '1.1.4-3'
    ext.firebase_version = '11.2.0'
    ext.support_version = '26.0.2'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta4'
        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:3.1.0'
    }    
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Any help? Thanks a lot!

like image 706
Zhyano Avatar asked Jul 28 '26 04:07

Zhyano


1 Answers

You should put apply plugin: 'com.google.gms.google-services' at the BOTTOM of your gradle file not the top.

https://developers.google.com/android/guides/google-services-plugin

like image 93
Kuffs Avatar answered Jul 30 '26 19:07

Kuffs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!