简体   繁体   English

将 firebase 消息传递服务添加到我的 AndroidManifest.xml 文件时,清单合并失败并出现多个错误

[英]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.

相关问题 清单合并失败:需要明确指定 android:exported<service> 即使我的 AndroidManifest.xml 文件中没有服务 - Manifest merger failed : android:exported needs to be explicitly specified for <service> even if there were no services in my AndroidManifest.xml file 清单合并失败并出现多个错误,请参阅日志 AndroidManifest.xml:requires a placeholder replacement but no value for - Manifest merger failed with multiple errors, see logs AndroidManifest.xml:requires a placeholder substitution but no value for 清单合并失败并出现错误,AndroidManifest.xml 的属性 provider#androidx.core.content.FileProvider@authorities 需要占位符 - Manifest merger failed with errors, Attribute provider#androidx.core.content.FileProvider@authorities at AndroidManifest.xml requires a placeholder 清单合并失败:属性 application@usesCleartextTraffic value=(true) from AndroidManifest.xml:29:9-44 - Manifest merger failed : Attribute application@usesCleartextTraffic value=(true) from AndroidManifest.xml:29:9-44 清单合并失败,出现多个错误 - Manifest merger failed with multiple errors AndroidManifest.xml文件 <manifest> versionCode属性 - AndroidManifest.xml file <manifest> versionCode attribute 清单合并失败,并出现多个错误 - Manifest merger failed with multiple errors 清单合并失败了吗?建议:添加&#39;工具:replace =“android:appComponentFactory”&#39;来 <application> AndroidManifest.xml中的元素:8:5-34:19以覆盖 - Manifest merger failed?Suggestion:add'tools:replace=“android:appComponentFactory”'to<application>element at AndroidManifest.xml:8:5-34:19 to overide 清单合并失败:AndroidManifest.xml:2:5-40 位置处的包名称“1”应至少包含一个“.” (点)字符 - Manifest merger failed: Package name '1' at position AndroidManifest.xml:2:5-40 should contain at least one '.' (dot) character 将Firebase UI添加到我的依赖项后,Android清单合并失败 - android manifest merger failed after adding Firebase UI to my dependency
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM