简体   繁体   English

具有多个清单的Android项目

[英]Android project with multiple manifests

I have an android studio project that has different folders being included depending on how the project is being built. 我有一个android studio项目,其中包含不同的文件夹,具体取决于项目的构建方式。

The file structure I am using looks like the following: 我正在使用的文件结构如下所示:

src/main/AndroidManifest.xml
        /java
        /res
src/FOO/AndroidManifest.xml
        /java
        /res

All of the configuration is done through gradle: 所有的配置都是通过gradle完成的:

java.srcDirs += <src/FOO/java>

The issue is that I am not sure how to use the manifest that would be located in the FOO directory in addition to a main manifest. 问题是,我不确定如何使用除主要清单之外的FOO目录中的清单。

Can this be done using manifest merging? 可以使用清单合并来完成吗? Or is this not an intended usage? 还是这不是预期的用法? Or does the manifest merger only look for manifests under directory the main manifest is located in? 还是清单合并仅在主清单所在目录下寻找清单?

I believe the manifest merger isn't aware of the manifest in src/FOO/AndroidManifest.xml. 我相信清单合并不知道src / FOO / AndroidManifest.xml中的清单。

The different paths that you describe should correspond to different build variants (flavour + build type combinations). 您描述的不同路径应对应于不同的构建变体(风味+构建类型组合)。 In each build variant directory you can include a different AndroidManifest.xml file that will be merged with the one in the main folder. 在每个构建变体目录中,您可以包括一个不同的AndroidManifest.xml文件,该文件将与主文件夹中的文件合并。 New (unknown) entries will simply be appended to the main AndroidManifest. 新的(未知)条目将简单地附加到主AndroidManifest中。 The tricky part comes when you will have "conflicting" entries in the different folders. 当您在不同文件夹中有“冲突”条目时,就会出现棘手的部分。 I would advise you to have a look at the documentation of the manifest merger, which can be found here . 我建议您查看清单合并的文档,可以在此处找到。 It is pretty explanatory, and it also includes a link to the Android Studio's Merged Manifest view tool and how to use it. 这很有解释性,并且还包含指向Android Studio的“合并的清单”视图工具以及如何使用它的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM