将Firebase消息传递服务添加到我的AndroidManifest.xml文件时,清单合并失败并出现多个错误 [英] Manifest merger failed with multiple errors when adding firebase messaging service to my AndroidManifest.xml file

查看:56
本文介绍了将Firebase消息传递服务添加到我的AndroidManifest.xml文件时,清单合并失败并出现多个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将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!

这是错误:

错误: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错误: 验证失败,正在退出 失败:构建失败,并出现异常.

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.

  • 出了什么问题: 任务':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文件时,清单合并失败并出现多个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆