Project already contains module with this name — Android Studio

爱⌒轻易说出口 提交于 2019-12-03 09:23:59

If somebody faces this issue, except removing the Folder containing the old module also remove from the settings.gradle file the line corresponding to the old module: include ':youroldmodule'. If you dont remove that line manually, 2 modules with the same name will appear when trying to add module dependency.

I have encountered this. And I deleted the folder which below my project with the module name I set before, then I can import a module with same name again.

Hope this helps you.

I solved the problem through this way:

  1. Open Module Settings(Mac: command + down; Windows: F4) and delete the module.
  2. Delete the module folder on the disk. You will find it at ~/AndroidStdioProjects/YourApplicationName/ModuleName.
  3. Import the Module.

The project view on the left hand side, doesn't show 'everything' your project contains. You can switch the view from the drop-down menu, which is defaulted to 'Android' and change it to 'Project Files', which will probably show you where the problematic reference to the Module remains.

Alternatively, just check on disk where your project is located. I found references in the main project folder.

You can't import a module if you've put the code for the module in the place it will end up being copied to. I had the module source code placed in the project root folder and it failed to import with the above message. If you move the code away somewhere, on import Android Studio will copy the code in.

Remove compile project(':module_name') from build.gradle under app folder

then remove module folder under your Project Folder

then remove your module name entry from settings.gradle

I am Not Sure but I hope it's Help you.

Step 1: Pressed Alt + 1 for get Focus of your App.

Step 2: Now Pressed F4 for open Module structure of Project

Step 3 Now Select Dependencies and Remove All Extra dependencies of your project.

than Pressed OK.

and Resync gradle.

I hope you are clear with my solution.

Best Luck

I had this problem when I was trying to add junit 4.12 to my project.First of all I delete old junit codes in dependencies of my build.gradle(app) file manually.Next I deleted the old junit.jar from my library with deleting libs folder and then create new libs folder directory in my app for add library.and for the end.......I find the old junit FILE near the end of project view after gradle folder....you can see in this image......and I deleted it.now I can add new module very easy and without same name error.sorry for bad english!! look this image for last order

I solved this by removing the existing module from the project structure, then renaming the folder. It finally worked when I removed the folder, ran a sync, then re-added the folder and attempted to import.

In one condition if you have copy a folder like this

rootProject/module1

if you import module android studio will find if you have same name folder. if you have it is not import android studio will tell you you have contains this module ,you just add this in setting.gradle like

include ':modlue1'

If shows this error after deleting the module from project structure then, select Project view of our project in android studio and then explore and the there will be the folder of module that we imported, right click on that and Delete it and rebuild the app.

If any of the above answers worked for you and you are sure that your branch is clean then close your Android Studio, browse to the root of your project and delete .idea folder. Then re-launch Android studio and run your project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!