Android - FirebaseApp/Firebase-Initialization 未启动 [英] Android - FirebaseApp / Firebase-Initialization is not starting
问题描述
我想在我的 Android 应用中实现 Firebase-Messaging 插件.我从 github 的quickstart-android-master/messaging"示例开始:https://github.com/firebase/quickstart-android/tree/master/messaging
这对我有用!日志输出:
D/FirebaseApp: com.google.firebase.auth.FirebaseAuth 未链接.跳过初始化.D/FirebaseApp﹕初始化的类 com.google.firebase.iid.FirebaseInstanceId.D/FirebaseApp﹕ com.google.firebase.crash.FirebaseCrash 未链接.跳过初始化D/FirebaseApp﹕初始化的类 com.google.android.gms.measurement.AppMeasurement.I/FirebaseInitProvider: FirebaseApp 初始化成功
<块引用>
但是如果我想实现插件com.google.firebase:firebase-messaging:9.0.2"进入我的应用程序,FirebaseApp 未初始化!所以 FirebaseApp 插件没有启动!- 没有收到日志或令牌!
我还在app"目录中的 build.gradle 文件中添加了应用插件:
应用插件:'com.android.application'安卓 {//...}依赖{//...编译 'com.google.firebase:firebase-messaging:9.0.2'}//在底部添加这个应用插件:'com.google.gms.google-services'
以及在根"目录中构建.gradle的google-services插件:
buildscript {//...依赖{//...类路径 'com.google.gms:google-services:3.0.0'}}
<块引用>
问题可能是:
- AndroidAnnotations、Proguard、产品风味...
我的问题是清单合并".如果我使用
xmlns:tools="http://schemas.android.com/tools"
和
tools:node="replace"
在Manifest的Application Tag中,FirebaseApp不会被初始化!
<块引用>如果您在 tools:node 上使用 replace attr,它将替换您的带有注释的较低优先级声明(查看更多此处).您应该使用 merge 或 merge only 属性相反.
我到底做了什么:
这不起作用:
<应用程序机器人:名称=xxx"android:icon="@mipmap/ic_launcher"android:label="@string/application_name"android:theme="@style/Theme.TemplateStyle"工具:节点=替换">
这有效:
<应用程序机器人:名称=xxx"android:icon="@mipmap/ic_launcher"android:label="@string/application_name"android:theme="@style/Theme.TemplateStyle"><!-- tools:node="replace"-->
<块引用>
如果要覆盖或替换某些属性,请改用tools:replace
!
I want to implement the Firebase-Messaging plugin into my Android-App. I've started with the "quickstart-android-master/messaging"-example from github: https://github.com/firebase/quickstart-android/tree/master/messaging
This works for me! Log-Output:
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!
I've also added apply plugin to build.gradle file in "app"-directory:
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'
And the google-services plugin to build.gradle in the "root" directory:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.0.0'
}
}
Problems could be:
- AndroidAnnotations, Proguard, Product flavors...
My problem was the "Manifest Merger". If I use the
xmlns:tools="http://schemas.android.com/tools"
and
tools:node="replace"
in the Application Tag of the Manifest, the FirebaseApp will not be initialized!
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.
So what I've exactly done:
This doesn't work:
<application
android:name="xxx"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
android:theme="@style/Theme.TemplateStyle"
tools:node="replace">
this works:
<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-Initialization 未启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!