FirebaseInitProvider: FirebaseApp の初期化に失敗しました 質問する

FirebaseInitProvider: FirebaseApp の初期化に失敗しました 質問する

私たちはAndroid プロジェクトに Firebase を追加するしかし、Firebase コンソールではアプリがデータを受信して​​いるのを確認できません。
アプリを起動すると、ログに次のように表示されます。

FirebaseInitProvider: FirebaseApp initialization unsuccessful

これはどういう意味ですか? 何が間違っているのでしょうか?
このエラーはドキュメントにも、StackOverflow にも見つかりません。

ベストアンサー1

これはどういう意味ですか? 何が間違っているのでしょうか?

認証が成功しなかったと想定されます。

a )buildscript repositoriesおよびdependenciesプロジェクトレベル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)dependenciesモジュールレベルapp/build.gradle(Android Intel x86イメージには、Google Play Servicesの以前のバージョンがインストールされている場合があります。たとえば、10.2.0現在のx86エミュレータでは実行されますが、たとえば、11.8.0物理ARMデバイスでは実行されます)。参照してplay-servicesfirebase-core次のものが含まれます。全て一部のモジュールを除外しない限り、そのモジュールのすべて。アップデート: 今ではすべてのライブラリを個別に参照する必要があります。 および はcom.google.android.gms:play‐servicescom.google.firebase:firebase-core以降は機能しなくなりました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次のようになります。

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

d) (ダウンロードした)認証情報が利用可能であることを確認しますapp/google-services.json。Firebaseコンソールで、以下を追加する必要があります。両方デバッグ用のSHA1(またはSHA256)ハッシュそして両方のビルドが適切に認証されるように、リリース キーが必要です。すべてが一致すると、次のように報告されます。

I/FirebaseInitProvider: FirebaseApp initialization successful

すべてはよく文書化されているので、見てくださいGoogle Play 開発者サービスを設定するFirebase クイックスタートまたはクラッシュレポート; Firebase ブログのこの記事は非常に役立つと思います:Firebase 対応 Android アプリのビルドを整理するクラッシュレポートを部分的にミュートする方法を説明しているためです。リリースノート常に更新と変更を発表します。

おすすめ記事