[英]Manifest merger failed with multiple errors when adding firebase messaging service to my AndroidManifest.xml file
I was hoping to add Firebase cloud messaging to my app.我希望将 Firebase 云消息传递添加到我的应用程序中。 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.我为此遵循了codelab教程,并且它在示例应用程序中正常工作,但是当我尝试将
<service>
标记添加到我的应用程序时,会发生 Manifest 合并错误。
The strange part is that it is working without adding those services to my Manifest file!奇怪的是,它在没有将这些服务添加到我的清单文件的情况下工作!
Here it is the error:这是错误:
Error:packageName/app/src/main/AndroidManifest.xml:52:9-58:19 Error: Element service#packageName.firebase.MyFirebaseInstanceIdService at AndroidManifest.xml:52:9-58:19 duplicated with element declared at AndroidManifest.xml:44:9-50:19 packageName/app/src/main/AndroidManifest.xml Error: Validation failed, exiting FAILURE: Build failed with an exception.
错误:packageName/app/src/main/AndroidManifest.xml:52:9-58:19 错误:AndroidManifest.xml:52:9-58:19 中的元素 service#packageName.firebase.MyFirebaseInstanceIdService 与 AndroidManifest 中声明的元素重复。 xml:44:9-50:19 packageName/app/src/main/AndroidManifest.xml 错误:验证失败,退出失败:构建失败,出现异常。
What went wrong: Execution failed for task ':app:processDebugManifest'.
出了什么问题:任务 ':app:processDebugManifest' 执行失败。 Manifest merger failed with multiple errors, see logs
清单合并失败并出现多个错误,请参阅日志
Try: Run with --stacktrace option to get the stack trace.
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。 Run with --debug option to get more log output.
使用 --debug 选项运行以获得更多日志输出。
And this is part of my AndroidManifest.xml file:这是我的 AndroidManifest.xml 文件的一部分:
<?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>
My question is that whether Firebase library adds these tags to my Manifest during building or something is wrong here?我的问题是 Firebase 库是否在构建过程中将这些标签添加到我的清单中,或者这里有什么问题?
You have the same service ( .firebase.MyFirebaseInstanceIdService
) listed twice.您列出了两次相同的服务 (
.firebase.MyFirebaseInstanceIdService
)。 This will not work.这是行不通的。 Either have one
<service>
element containing two <intent-filter>
elements, or have two separate services with separate classes.要么有一个包含两个
<intent-filter>
元素的<service>
元素,要么有两个具有不同类的独立服务。
我遇到了同样的问题,并通过将 minSdkVersion 的值从 15 更改为 16 来解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.