You cannot have two "projects" as a single project in Android Studio.
Convert one (or both) project into libraries. Then create a "shell" project to build each app. The shell project is basically empty, or it may have build specific value overrides. The advantage here is that you can modify the library and changes will be immediately reflected in both/all versions. The drawback is that you will have to fix any issues in all projects that result from any change to any library. But you can then create the "combined" project in a similar manner.
After you convert one or both to a library you can create an aar
file. This gives you the option to then include that aar
as a gradle dependency. Be careful to remember that you will need to re-build the aar
every time you modify that project - so if you have an indication as to which is the more stable codebase, go with that for the aar
. This gives you the ability to "version control" the main project dependency so that you can make changes to one project without impacting the stability of the other.
Additionally, you can write scripts and use tools like Bamboo or Jenkins to do real-time updates to the aar
- but that is like using a "snapshot" dependency. When you change the aar
it may compile, but it may break the build of the second project without you knowing it until you do a build on that project. (And yes, you can include a build on that project as a part of the Bamboo or Jenkins script, but it isn't easy.)
There may be other alternatives, but these seem to offer enough options to produce a wide variety of build options.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…