合并在Android的工作室模块? [英] Merging modules in Android Studio?

查看:201
本文介绍了合并在Android的工作室模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我在几个模块一直在努力,我的'主'一个是编译,然后那些在那里我摆弄某些功能和库,直到我得到的功能来工作,我想要的方式不会破坏我的主要模块。我现在要合并的资源和类的我一塌糊涂,周围模块变成我的'主'模块之一,而不必去到个人迪尔斯复制和粘贴(如子目录中的SRC),然后系统地通过所有的错误弹出,因为类路径已经改变了这样或那样的。

So I've been working in several modules, my 'primary' one that is compilable, and then ones where I mess around with certain features and libraries until I get that feature to work the way I want without breaking my primary module. I now want to merge the resources and classes of one of my mess-around-modules into my 'primary' module without having to go to individual dirs to copy and paste (e.g. subdirs in src), and then systematically go through all of the errors that pop-up because the class path has changed for such and such.

有没有办法合并两个模块,而无需做上面,基本上合并构建,源,库?最接近的是我能找到的是重构>移动,但仅此而已,是无处接近是一个可行的解决方案。

Is there a way to merge two modules without having to do the above, basically merge build, src, libs? The closest thing I can find is Refactor>Move, but that's it and is nowhere close to being a viable solution.

推荐答案

在构建一个多模块项目,如果两个或多个模块定义具有相同名称的资源,从更高的优先级模块中的资源将被选中。

When building a multi-module project, if two or more modules have defined a resource with same name, the resource from the higher priority module will be selected.

您可以通过打开项目结构改变模块的相对优先级(文件 - >项目结构/按Ctrl + Alt + Shift + S),并点击向上和向下箭头,在依存关系选项卡

You can change the relative priority of modules by opening Project Structure (File -> Project Structure / Ctrl+Alt+Shift+S) and clicking on up and down arrow, in Dependencies tab.

如果您要添加引用多个库,你可以设置其相对优先级(和合并顺序)选择一个库,并使用向上和向下控制。这些工具合并引用的库与您的应用程序从最低优先级(列表的底部)开始最高(在列表的顶部)。如果一个以上的库定义相同的资源ID,该工具从库中选择具有较高优先级的资源。应用程序本身具有最高的优先级和它的资源总是使用preference在库中定义相同的资源ID。    https://developer.android.com/sdk/installing/create-project.html

If you are adding references to multiple libraries, you can set their relative priority (and merge order) by selecting a library and using the Up and Down controls. The tools merge the referenced libraries with your application starting from lowest priority (bottom of the list) to highest (top of the list). If more than one library defines the same resource ID, the tools select the resource from the library with higher priority. The application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries. https://developer.android.com/sdk/installing/create-project.html

另外的manifest.xml文件将被或多或少直观地合并。在不同的文件中同一节点的属性加起来,除非有这将引发异常,你必须解决的矛盾冲突。每个模块的清单的不同的节点将被加入到最终的清单。例如,你可以定义一个库模块的manifest.xml的服务,无所添加到主模块清单文件,一切都会好起来的。

Also manifest.xml files will be merge more or less intuitively. Attributes of a same node in different files add up unless there is a conflict which will raise exception and you must resolve the conflict. Different nodes of each module's manifest will be added to the final manifest. For example you can define a service in a library module's manifest.xml without adding anything to the main modules manifest file and everything will be fine.

您可以阅读更多有关清单合并这里

You can read more about manifest merging here.

这篇关于合并在Android的工作室模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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