Android清单合并失败接收机具有相同的名称但不同的内容接收机、清单、名称、不同

由网友(缺鋅缺鈣缺伱愛⌒_⌒)分享简介:我有问题,明显的合并与复制接收器,但内容不同。我用不同的API级别以下的接收器,没有任何问题,到目前为止,直到合并。构建失败,因合并而称元素接收#.receivers.UpdateReceiver复制与在AndroidManifest.xml中声明的元素:124:9我不想再创建一个接收器,并继续与这个模式。有没有什么办...

我有问题,明显的合并与复制接收器,但内容不同。我用不同的API级别以下的接收器,没有任何问题,到目前为止,直到合并。构建失败,因合并而称

 元素接收#.receivers.UpdateReceiver复制与在AndroidManifest.xml中声明的元素:124:9
 

我不想再创建一个接收器,并继续与这个模式。有没有什么办法来禁用合并对于这种情况,或在一但让行动不同意图的选项合并接收器?

 <接收器
    机器人:名称=。receivers.UpdateReceiver
    机器人:启用=@布尔/ is_api_below_12>
    <意向滤光器>
        <作用机器人:名称=android.intent.action.PACKAGE_REPLACED/>
        <数据机器人:计划=包/>
    &所述; /意图滤光器>
< /接收器>

<接收器
    机器人:名称=。receivers.UpdateReceiver
    机器人:启用=@布尔/ is_api_12_and_above>
    <意向滤光器>
        <作用机器人:名称=android.intent.action.MY_PACKAGE_REPLACED/>
    &所述; /意图滤光器>
< /接收器>
 

解决方案 如何修改安卓软件

您可以找到我如何这个答案固定你的完全一样的问题。基本上,我创建了另一个类,但我做了一个静态内部类,以避免创建另一个文件来处理共同行动。

I'm having problem with manifest merger with duplicated receivers but the content is different. I use the following receivers for different API levels, had no issue so far until merger. Build fails due to merger which says

Element receiver#.receivers.UpdateReceiver duplicated with element declared at AndroidManifest.xml:124:9

I don't want to create another receiver and continue with this schema. Is there any way to disable merger for those situations or merge the receivers in one but with the option of enabling action with different intent?

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_below_12">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REPLACED" />
        <data android:scheme="package" />
    </intent-filter>
</receiver>

<receiver
    android:name=".receivers.UpdateReceiver"
    android:enabled="@bool/is_api_12_and_above">
    <intent-filter>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
    </intent-filter>
</receiver>

解决方案

You can find how I fixed your exact same issue in this answer. Basically I created another class, but I made it an static inner class to avoid creating another file to handle a common action.

阅读全文

相关推荐

最新文章