问题描述
我希望将Firebase云消息传递添加到我的应用程序中.我遵循了 codelab 教程,它在示例应用程序中正常运行,但是当我尝试向应用程序中添加<service>
标签时,会出现清单合并错误.
I was hoping to add Firebase cloud messaging to my app. I followed codelab tutorial for this and it was working correctly for the sample app, but when I try to add <service>
tags to my application Manifest merger errors occurs.
奇怪的是,它可以正常运行,而无需将这些服务添加到我的清单文件中!
The strange part is that it is working without adding those services to my Manifest file!
这是错误:
-
出了什么问题: 任务':app:processDebugManifest'的执行失败. 清单合并失败,并出现多个错误,请参阅日志
What went wrong: Execution failed for task ':app:processDebugManifest'. Manifest merger failed with multiple errors, see logs
尝试: 使用--stacktrace选项运行以获取堆栈跟踪.使用--debug选项运行,以获取更多日志输出.
Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
这是我的AndroidManifest.xml文件的一部分:
And this is part of my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.violete.selfienight">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="net.violete.selfienight.leafpic.MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.FullScreen">
<activity
android:name=".CameraActivity"
android:icon="@mipmap/ic_launcher"
android:label="@string/title_camera_activity"
android:screenOrientation="landscape"
android:taskAffinity=".CameraActivity"
android:theme="@style/AppTheme.FullScreen">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<service
android:name=".firebase.MyFirebaseInstanceIdService"
>
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".firebase.MyFirebaseInstanceIdService"
>
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
...
</application>
</manifest>
我的问题是Firebase库是否在构建过程中将这些标签添加到我的清单中,还是这里有问题?
My question is that whether Firebase library adds these tags to my Manifest during building or something is wrong here?
推荐答案
您两次列出了相同的服务(.firebase.MyFirebaseInstanceIdService
).这是行不通的.要么有一个包含两个<intent-filter>
元素的<service>
元素,要么有两个具有单独类的单独服务.
You have the same service (.firebase.MyFirebaseInstanceIdService
) listed twice. This will not work. Either have one <service>
element containing two <intent-filter>
elements, or have two separate services with separate classes.
这篇关于将Firebase消息传递服务添加到我的AndroidManifest.xml文件时,清单合并失败并出现多个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!