FirebaseInitProvider:FirebaseApp 初始化不成功 [英] FirebaseInitProvider: FirebaseApp initialization unsuccessful

查看:94
本文介绍了FirebaseInitProvider:FirebaseApp 初始化不成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已按照将 Firebase 添加到您的 Android 项目,但我们在Firebase 控制台.
当我们启动应用程序时,日志显示:

We have followed the Add Firebase to your Android Project but we can't see the app receiving data in the Firebase Console.
And when we launch the app, the log says:

FirebaseInitProvider: FirebaseApp initialization unsuccessful

这是什么意思?我们做错了什么?
我在文档中找不到此错误,在 StackOverflow 中也找不到.

What does this mean? What are we doing wrong?
I can't find this error in the docs, nor here in StackOverflow.

推荐答案

这是什么意思?我们做错了什么?

What does this mean? What are we doing wrong?

假设身份验证没有成功.

Would assume, that the authentication did not succeed.

a) buildscript repositoriesdependencies 用于 project 级别 build.gradle:

a) the buildscript repositories and dependencies for the project level build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        
        // Android Gradle Plugin
        classpath "com.android.tools.build:gradle:3.3.2"

        // Google Services Plugin
        classpath "com.google.gms:google-services:4.2.0"
    }
}

b) 模块app/build.gradledependencies(Android Intel x86 映像可能仍具有以前版本的安装的 Google Play 服务,例如 10.2.0 在当前的 x86 模拟器上运行,而例如 11.8.0 在我的物理 上运行代码>ARM 设备).引用 play-servicesfirebase-core 将包括它们的所有模块,除非排除一些模块.更新:现在必须单独引用所有库.引用 com.google.android.gms:play-servicescom.google.firebase:firebase-core15.0.0 不再工作>.

b) the dependencies for the module level app/build.gradle (the Android Intel x86 images may still have a previous version of the Google Play Services installed, eg. 10.2.0 runs on the current x86 emulator, while eg. 11.8.0 runs on my physical ARM device). referencing play-services and firebase-core will include all of their modules, unless excluding some them. update: one has to reference all the libraries individually now. referencing com.google.android.gms:play‐services and com.google.firebase:firebase-core does not work anymore since 15.0.0.

android {
    ...
    buildTypes {
        debug {
            // suffixing the package name for debug builds,
            // in order to partially mute the crash-reporting
            // is an *optional* configuration (see below):
            applicationIdSuffix ".debug"
        }
    }
}

dependencies {

    // Google Play Services
    // https://developers.google.com/android/guides/releases
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.android.gms:play-services-auth:16.0.0"
    implementation "com.google.android.gms:play-services-identity:15.0.1"

    // Google Firebase
    // https://firebase.google.com/support/release-notes/android
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-auth:16.0.3"
    implementation "com.google.firebase:firebase-config:16.0.0"
    implementation "com.google.firebase:firebase-storage:16.0.1"
    implementation "com.google.firebase:firebase-database:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.3.0"
    implementation "com.google.firebase:firebase-appindexing:16.0.1"
    implementation "com.google.firebase:firebase-functions:16.1.0"
    implementation "com.google.firebase:firebase-invites:16.0.1"
    // implementation "com.google.firebase:firebase-crash:16.0.1"
    implementation "com.google.firebase:firebase-ads:15.0.1"
    implementation "com.google.firebase:firebase-firestore:17.0.4"
    implementation "com.google.firebase:firebase-perf:16.0.0"

    // the inapp messaging may cause dependency conflicts: 
    // implementation "com.google.firebase:firebase-inappmessaging:17.0.0"
    // implementation "com.google.firebase:firebase-inappmessaging-display:17.0.0"
}

c) mobile/build.gradle 的底线应该是:

c) the bottom line of mobile/build.gradle should be:

// apply the Google Services Plugin
apply plugin: "com.google.gms.google-services"

d) 确保在 app/google-services.json 中提供(下载的)凭据;在 Firebase 控制台上,必须添加两个 SHA1(或 SHA256)哈希,调试发布密钥,以便使两个构建都正确地进行身份验证;一旦全部匹配,它应该报告:

d) make sure to have the (downloaded) credentials available at app/google-services.json; on the Firebase Console, one has to add both SHA1 (or SHA256) hashes, of the debug and the release keys, in order to have both builds authenticating properly; once it all matches, it should report:

I/FirebaseInitProvider: FirebaseApp initialization successful

这一切都有据可查,只需查看设置 Google Play 服务Firebase 快速入门崩溃报告;虽然我发现 Firebase 博客上的这篇文章非常有用:组织启用 Firebase 的 Android 应用构建,因为它解释了如何部分静音崩溃报告.发行说明 总是会宣布更新和更新.变化.

It's all well documented, just see Setup Google Play Services, Firebase Quickstart or Crash Reporting; while I find this article on the Firebase Blog quite useful: Organizing your Firebase-enabled Android app builds, because it explains how to partially mute the crash-reporting. The release notes always announce the updates & changes.

这篇关于FirebaseInitProvider:FirebaseApp 初始化不成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆