Bitwise DEVS
Bitwise DEVS

Reputation: 3469

How to add module inside an Android module?

Having the following structure.

-root

How to add module inside an Android module? This means that the module2 should still detect the submodule even without having specifying it in settings.gradle.

Currently implementation(project(":libs:submodule")) in build.gradle.kts of module2 is not working. It will work however if we do this

-root

This is when we specified the submodule in settings.gradle

rootProject.name = "Sample App"
include(":app")
include(":module1")
include (":module2") // Has dependency to submodule
include (":submodule")

But what we want is for module2 to already include submodule so we don't need to specify in the project the submodule.

Upvotes: 0

Views: 216

Answers (1)

Haseeb Hassan Asif
Haseeb Hassan Asif

Reputation: 895

None of the modules are dependent on any other unless they are mentioned in build.gradle file of another module.

For creating module inside a module you can just move it to another module and update its directory graph in settings.gradle file appropriately.

So, I created two new modules test1, test2. I now created a new directory called tests. after this I moved my two modules from project directory to tests directory. I edit my settings.gradle file which had

include ':app'
include ':translations'
include ':test1'
include ':test2'

and updated it to following:

include ':app'
include ':translations'
include 'tests:test1'
include 'tests:test2'

then I created another directory inside tests directory called subtest and moved the test2 module there. then i updated my settings.gradle file to

include ':app'
include ':translations'
include 'tests:test1'
include 'tests:subtest:test2'

And I did it in the project configuration like in the following image:

enter image description here

and now it looks something like:

enter image description here

Upvotes: -2

Related Questions