Android App + Firebase初始化失败

时间:2018-12-03 14:28:07

标签: android firebase

对于我的Android应用,我需要集成Firebase。所以我遵循了谷歌教程。

现在我总是在实现Firebase之后得到

E/FirebaseApp: Firebase API initialization failure.

当我运行应用程序时(在真实设备和仿真上)

已经看到:Firebase database dependency crashes app 但他正在使用旧版本...

所以我的依赖关系如下:

   dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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.google.android.gms:play-services-location:16.0.0'
    //implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.5'
}
apply plugin: 'com.google.gms.google-services'

这里是项目的摇篮:

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.1'



    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

有人知道该怎么做才能解决这个初始化问题?

1 个答案:

答案 0 :(得分:0)

我认为,不要添加“ com.google.android.gms:play-services:”,而是确定playservices需要什么。由于Play服务中塞满了22个程序包,因此您可能不会使用所有程序包。这将使apk大小膨胀,并且您可能会在项目中越过65K methods

我建议您通过此link并从playservices中选择所需的东西。