Android Studio: Why my new project contains 2 modules

In the new Android Studio project, when I look at the project structure, there are 2 modules. One is ProjectName and the other is ProjectName-ProjectName. Did I do something wrong while creating the project?

Android Studio Project Structure

+4
source share
2 answers

When creating new projects, we always create a top-level project with one module in it. Studio or IntelliJ will show both in the list of modules, but the top one ("testing") will not work anyway.

We do this instead of a flat structure in the root project, so that it will allow you to easily add new modules (e.g. libraries) later without having to convert the structure of your project.

what’s important is that the testing-testing module (at some point we’ll probably rename this “test-testing”). another module does nothing. If you look at its build.gradle, it is empty, and the other will declare an Android project.

+7
source

I have a similar set of .iml files, like yours, using the old version of Android Studio, but after upgrading to a later version, he created another .iml, so there was a top-level project.iml project with a module containing module.iml and module-module.iml.

As far as I could tell, the module-module.iml file was useless, and the key information was in the .iml module. However, even if I delete all the iml files, Android Studio will restore them all, so I realized that it stores enough information in [project] /. Idea / modules.xml to recreate iml files from scratch.

So, I left Android Studio, deleted the .idea folder and .iml files, and then restarted Android Studio and imported the project using build.gradle files. He recreated only project.iml and module.iml, and everyone is happy.

SUMMARY: As long as your gradle.build files are clean, you can delete the .idea and .iml files, import the project using gradle files, and get a nice clean project structure.

0
source

Source: https://habr.com/ru/post/1481465/


All Articles