Gradle:如何为需要相同活动但具有不同意图过滤器的不同构建类型合并 Android 清单文件 [英] Gradle: How to merge Android manifest files for different buildTypes which need the same Activity, but with different intent-filters

查看:24
本文介绍了Gradle:如何为需要相同活动但具有不同意图过滤器的不同构建类型合并 Android 清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用 gradle 创建一个单独的 buildType,但是那个 buildType 需要为同一个 Activity 使用不同的特征.在这种情况下,我的启动活动需要一个不同的意图过滤器,具体取决于 buildType.这可能吗?

so I'm trying to use gradle to create a separate buildType, but that buildType needs to use different characteristics for the same Activity. In this case, my splash activity needs a different intent-filter depending on buildType. Is this possible?

我在 gradle 中收到以下错误:

I get the following error in gradle:

:Tinder:processUtestManifest
[AndroidManifest.xml:67, AndroidManifest.xml:38] Trying to merge incompatible /manifest/application/activity[@name=com.<company_name>.activities.ActivitySplash] element:
  <activity
      @android:name="com.<company_name>.activities.ActivitySplash"
      <intent-filter>
          <action
--            @android:name="android.intent.action.MAIN">
  <activity
      @android:name="com.<company_name>.activities.ActivitySplash"
      <intent-filter>
          <action
++            @android:name="com.apphance.android.LAUNCH">

推荐答案

目前无法单独合并意图过滤器,因此我建议将整个 节点复制到

It's not possible to merge the intent-filter separately at the moment so I would recommend copying the whole <activity> node into

src/buildtype1/AndroidManifest.xml

src/buildtype2/AndroidManifest.xml

它会自动合并到最终清单中(当然您也想将其从主清单中删除).

and it'll get merged automatically into the final manifest (of course you also want to remove it from the main manifest).

这篇关于Gradle:如何为需要相同活动但具有不同意图过滤器的不同构建类型合并 Android 清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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