I need to write a lot of trivial modules and I don't want to hide the main modules between them. For this reason I want to have a directory tree like this:
Project
|-module1
|-module2
+-directory
|-module3
|-module4
+-module5
The problem: if I move the modules inside a new folder Android Studio doesn't find them.
So, my question is: How can I move modules inside a directory?
I would recommend closing the project in Android Studio, moving the directories manually in your OS, and updating the project's settings.gradle file to point to the modules in their new location. Using your example, the updated settings.gradle file will look like this:
include ':module1'
include ':module2'
include ':directory:module3'
include ':directory:module4'
include ':directory:module5'
Then re-open the project in Android Studio, and make sure it syncs the project with the new Gradle files (which it should do automatically, but if it doesn't, click the toolbar button for it).
You can now define the location of modules with
include ':myModule'
project(':myModule').projectDir = new File('dir/myModule')
Further, you have to remove the .iml files under the module directory to let Android Studio recreate them.
You can simply add them as a new module.
Android
in your case. Then select the Android module typeProject\directory\module3
By default, in the project tool window tree, it will show a flat structure of:
Project
+-Module1
+-Module2
+-Module3
+-Module4
+-Module5
If you want to add a hierarchy to the project tree structure:
modules
panel on the left. Now in the project tool window, those modules will be grouped into a hierarchy.
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