简体   繁体   English

Android App + Firebase初始化失败

[英]Android App + Firebase initializations fail

for my Android App, I need firebase integrated. 对于我的Android应用,我需要集成Firebase。 So I followed the google tutorial. 所以我遵循了谷歌教程。

now I am always getting after implementing firebase 现在我总是在实施firebase后得到

E/FirebaseApp: Firebase API initialization failure.

when I run the App (on Real Device and Simulation) 当我运行应用程序时(在真实设备和仿真上)

Already saw that: Firebase database dependency crashes app but he is working with old versions... 已经看到: Firebase数据库依赖项使应用程序崩溃,但他正在使用旧版本...

So my dependencies look like this: 所以我的依赖关系如下所示:

   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'

here the projects gradle: 这里的项目gradle:

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
}

does anybody know what to do to get rid of this initalization problem? 有谁知道该怎么做才能消除这个初始化问题?

I think, instead of adding "com.google.android.gms:play-services:", identify what is needed from playservices. 我认为,不要添加“ com.google.android.gms:play-services:”,而是确定playservices需要什么。 Because play services is stuffed with 22 packages and you might not using all of it. 由于Play服务中塞满了22个程序包,因此您可能不会使用所有程序包。 This will bloat the apk size and you might cross 65K methods in your project. 这将使apk大小膨胀,并且您的项目中可能会越过65K个方法

I'd advice, you go through this link and pick necessary things you need from playservices. 我建议您通过此链接从playservices中选择所需的必要内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM