More than one module found in a single module project. 关注
Hi, Yann Cebron , I have a Android Studio project with only one module created whose module name is 'app'. But when I use
in my plugin code, it will give me four modules sometimes. See attached image.
Only the module 'app' is created by me. I don't know why there are other three modules 'androidTest', 'unitTest' and 'main'.
Not sure whether there are some other APIs I should use instead of this one. I did some trials. When I reduce the Gradle version from 4.2.2 to 4.0.1 and change the
in gradle-wrapper.properties into
this issue will disappear as follows.
Thanks in advance!
I would assume these additional modules are created by some Android-related functionality and depend on Android-related plugins/functionality coming from the Gradle build script/setup.
Yann Cebroni. Thanks for the reponse. Do you know what we can do in the Gradle build script to fix this?
I'm sorry but this is out of scope for support. Please review Google's Development Docs.
Will Intellij have APIs in the future to support filtering real app modules(app) from other instrumented tests(app.androidTest, app.unitTest)?
Since Android Studio version Chipmunk, Android Studio uses module-per-[gradle]-source-set module structure mode.
To understand this better, let's take a look at the image of the module project structure of the My_Application231 example Android project.
We can see that the example project has a root project (My_Application213) module, which serves as a container. The root project module contains the app module, which also serves as a container and doesn't have any sources. Instead, the app module contains a module per source set:
Android Studio has its own Project Structure dialog, and in the UI it filters out the project root module and test modules from the list of shown modules. That is why it was not clear why ModuleManager returns additional modules.
To get only app module, you can probably take a look at the following method com.android.tools.idea.gradle.project.ProjectStructure#getAppHolderModules and how it is used. If this doesn't work for you, I think you'll have to implement your own filtering to remove the project root module and test modules.
Nebojsa Vuksic Hi Nebojsa, thank you so much for the answer.
I found the other 3 additional modules don't appear under 'project structure' or on the left directory in Android Studio Dolphin. It will appear in Androd Studio 4.2.1.
Do you know the reason? Of course, they will appear in my plugin when i use the module manager to read them out. Thank you.