How to add firebase-admin to my android project?

2019-01-12 07:51发布

问题:

Why when I try to add firebase-admin into my android project, the gradle tells me that "Version 5.5.0 is lower than the minimum version (9.0.0) required for google-services plugin" But version 5.5.0 of firebase-admin it's latest at this moment. WTH?

build.gradle

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.github.bumptech.glide:glide:4.3.1'
    compile 'com.github.GrenderG:Toasty:1.2.5'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
    compile group: 'com.google.firebase', name: 'firebase-admin', version: '5.5.0'
    compile 'com.google.firebase:firebase-core:11.6.2'
    compile 'com.google.firebase:firebase-database:11.6.2'
    compile 'com.google.firebase:firebase-auth:11.6.2'
    compile 'com.google.android.gms:play-services-auth:11.6.2'
    implementation 'com.google.firebase:firebase-storage:11.6.2'
    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'

回答1:

firebase-admin is not intended for use in Android apps. It's for accessing Firebase services from servers your control.

From the documentation regarding prequisites:

Before you begin, make sure you have the following:

- If using the Admin Node.js SDK, a server running Node.js 4.0+
- If using the Admin Java SDK, a server running Java 7+
- If using the Admin Python SDK, a server running Python 2.7+ or 3.x
- A server app

The google-services plugin is giving you that warning because it thinks every maven target with group "com.google.firebase" is actually a Firebase Android client SDK, which all must be the same version in your app.