摇篮合并封装/子模块的Andr​​oid清单到主模块的清单 [英] Gradle merge wrapper/sub-module's Android manifest into a main module's manifest

查看:311
本文介绍了摇篮合并封装/子模块的Andr​​oid清单到主模块的清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的项目中下面的模块,我不能让摇篮合并了Android舱单正确:

I have the following modules inside my project for which I cannot get Gradle to merge the Android manifests properly:

myproject_alpha<br>
myproject_beta<br>
myproject_lib<br>
myproject_release<br>

* _lib模块是包含所有源$ C ​​$ c中的项目的主模块。其他3个模块都是包装模块,使轻微的修改,以内容提供商的权威的参数,改变数据字段中的* _lib模块的清单中指定的活动的意图过滤器里面,再加上启用一些其他活动没有present myproject_release模块中。

The *_lib module is the main module for the project that contains all source code. The other 3 modules are "wrapper modules" that make slight modifications to the content providers' "authorities" parameter, change the "data" field inside an activity's intent filter specified in the *_lib module's manifest, plus enable some other activities not present in myproject_release module.

目前,我的gradle有Android清单合并α(或β或释放)VS LIB之间的误差。例如,lib和阿尔法之间我看到下面的2 gradle这个错误:

Currently, I have gradle Android manifest merging errors between alpha (or beta or release) vs lib. For example, between lib and alpha I see the following 2 gradle errors:

Trying to merge incompatible /manifest/application/provider[@name=com.myproject.contentprovider.MyProvider] element:
  <provider
--    @android:authorities="com.myproject.alpha.provider"
  <provider
++    @android:authorities="com.myproject.lib.provider"

:myproject_alpha:processDebugManifest FAILED

Trying to merge incompatible /manifest/application/activity[@name=com.myproject.activity.LoginActivity] element:
  <activity
  @android:name="com.myproject.activity.LoginActivity"
          @android:name="android.intent.action.MAIN">
          @android:name="android.intent.category.LAUNCHER">
  <intent-filter>
          @android:name="android.intent.action.VIEW">
          @android:name="android.intent.category.BROWSABLE">
          @android:name="android.intent.category.DEFAULT">
      <data
--            @android:host="myhost.test.com"
  <activity
  @android:name="com.myproject.LoginActivity"
          @android:name="android.intent.action.MAIN">
          @android:name="android.intent.category.LAUNCHER">
  <intent-filter>
          @android:name="android.intent.action.VIEW">
          @android:name="android.intent.category.BROWSABLE">
          @android:name="android.intent.category.DEFAULT">
      <data
++            @android:host="myhost.com"

:myproject_alpha:processDebugManifest FAILED

唯一类似的问题,我发现了结果
<一href=\"http://stackoverflow.com/questions/18708076/gradle-how-to-merge-android-manifest-files-for-different-buildtypes-which-need\">Gradle:如何合并Android清单文件需要相同的活动不同buildTypes,但与不同的意图过滤器。但是,它并没有真正符合我的问题,因为在我的情况LIB和阿尔法是相互独立的模块没有什么不同的构建。我将AP preciate一些反馈。

The only similar question I found was
Gradle: How to merge Android manifest files for different buildTypes which need the same Activity, but with different intent-filters. However, it doesn't really match my issue because in my case "lib" and "alpha" are interdependent modules not different builds. I'll appreciate some feedback.

推荐答案

如果您检查<一个href=\"https://android.googlesource.com/platform/tools/base/+/master/build-system/manifest-merger/src/main/java/com/android/manifmerger/ManifestMerger.java\"相对=nofollow>类合并舱单中,您将看到 mergeNewOrEqual()方法是不够聪明,合并不相同的元素。不幸的是,这是用于合并提供商和活动方法

If you examine the class that merges the manifests, you'll see that the mergeNewOrEqual() method is not smart enough to merge elements that are not identical. Unfortunately, this is the method that is used to merge providers and activities.

因此​​,唯一的解决方案将是要么只在一个地方定义的元素,或给他们两个定义相同的签名。

So the only "solution" would be to either to only define the elements in one place, or to give them identical signatures in both definitions.

这篇关于摇篮合并封装/子模块的Andr​​oid清单到主模块的清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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