gpt4 book ai didi

Android - FirebaseApp/Firebase 初始化未启动

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:22:59 26 4
gpt4 key购买 nike

我想在我的 Android 应用程序中实现 Firebase-Messaging 插件。我从 github 中的“quickstart-android-master/messaging”示例开始:https://github.com/firebase/quickstart-android/tree/master/messaging

这对我有用!日志输出:

D/FirebaseApp﹕ com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
D/FirebaseApp﹕ Initialized class com.google.firebase.iid.FirebaseInstanceId.
D/FirebaseApp﹕ com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization
D/FirebaseApp﹕ Initialized class com.google.android.gms.measurement.AppMeasurement.
I/FirebaseInitProvider﹕ FirebaseApp initialization successful

But if I want to implement the Plugin "com.google.firebase:firebase-messaging:9.0.2" into my app, the FirebaseApp isn't initialized! So the FirebaseApp plugin isn't starting! - No Log or token received!

我还在“app”目录中的 build.gradle 文件中添加了应用插件:

    apply plugin: 'com.android.application'

android {
// ...
}

dependencies {
// ...
compile 'com.google.firebase:firebase-messaging:9.0.2'
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

以及“根”目录中 build.gradle 的 google-services 插件:

buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}

Problems could be:

  • AndroidAnnotations、Proguard、产品风格...

最佳答案

我的问题是“Manifest Merger”。如果我使用

xmlns:tools="http://schemas.android.com/tools"

tools:node="replace"

在Manifest的Application Tag中,FirebaseApp不会被初始化!

If you use replace attr on tools:node it will replace your lower priority declaration with the annotated one (see more here). You should use merge or merge only attributes instead.

那么我到底做了什么:

这行不通:

<application
android:name="xxx"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
android:theme="@style/Theme.TemplateStyle"
tools:node="replace">

这个有效:

<application
android:name="xxx"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
android:theme="@style/Theme.TemplateStyle">
<!-- tools:node="replace"-->

If you want to overwrite or replace some attributes, use tools:replace instead!

关于Android - FirebaseApp/Firebase 初始化未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37724761/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com