Manifest merger failed with multiple errors when adding firebase messaging service to my AndroidManifest.xml file

纵然是瞬间 提交于 2020-01-02 12:24:10

问题


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!

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.

  • What went wrong: Execution failed for task ':app:processDebugManifest'. Manifest merger failed with multiple errors, see logs

  • Try: Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

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>

My question is that whether Firebase library adds these tags to my Manifest during building or something is wrong here?


回答1:


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.



来源:https://stackoverflow.com/questions/40116839/manifest-merger-failed-with-multiple-errors-when-adding-firebase-messaging-servi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!