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.
From Project view, click right click your project root and follow New/Module. 1. b. And then, choose "Import Gradle Project".
The manifest merger tool combines all XML elements from each file by following some merge heuristics and by obeying merge preferences that you have defined with special XML attributes. This page describes how manifest merging works and how you can apply merge preferences to resolve merge conflicts.
A project with multiple Gradle modules is known as a multi-module project.
Modules. A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules, and one module may use another module as a dependency. You can independently build, test, and debug each module.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With