Search code examples
android-studiogradleandroid-module

module named 'app' already exists on Android Studio


I did something wrong and I don't know what I did. But the module name has been changed to my-android-app.

And I am trying to get it back to app. The default name of single module.

I tried Rename Module. But I get.

in the drop down menu of build, there are my-android-app and app. But I just have one build.gradle of module from my-android-app.

In the project structure. I just have my-android-app. Nothing to delete.

How can I fix this problem?


Solution

    1. You need to rename *.iml file(IntelliJ IDEA Module). This is the name of module. This file describes about the module.

    2. Edit configuration if you see two.

    enter image description here

    1. Delete all except for app. And change Name to app if its name is different.

    enter image description here

    1. .idea >your-app.iml`
    <?xml version="1.0" encoding="UTF-8"?>
    <project version="4">
      <component name="ProjectModuleManager">
        <modules>
          <module fileurl="file://$PROJECT_DIR$/app/your-app.iml" filepath="$PROJECT_DIR$/app/your-app.iml" />
          <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
        </modules>
      </component>
    </project>
    
    1. Delete one of them. (Maybe your-app.iml module tags.) Or if the location is incorrect then fix it.
    2. File > Invalidate Caches & Restart.
    3. Clean Build.