'Project already contains module with this name -- Android Studio
I had successfully imported a Module
in my Application project in Android Studio
.
Then I deleted or removed the module by following the below link:
How to delete a module in Android Studio
I also removed the project module from the dependencies
of my build.gradle(app)
file.
Now, When I need to again include the same module project in my Andorid Application, it doesn't allows me, and gives the Project already contains module with the same name
error.
I had check in my Project, Package, Android
Structure but the project module which i need to Import and add as a Module Project is not there but still it say it already exist.
Can anyone help me to overcome this issue.??
Solution 1:[1]
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.
Solution 2:[2]
Switch to the Project
View. Then open .idea/modules.xml
. Find and delete the line that corresponds to the module. Then Invalidate Caches and Restart. That's it.
Solution 3:[3]
I solved the problem through this way:
- Open Module Settings(Mac: command + down; Windows: F4) and delete the module.
- Delete the module folder on the disk. You will find it at ~/AndroidStdioProjects/YourApplicationName/ModuleName.
- Import the Module.
Solution 4:[4]
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.
Solution 5:[5]
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.
Solution 6:[6]
If you still see the error after removing the code from settings.gradle
and the app gradle file, check the following file and remove any entries with the module name you are trying to remove.
./.idea/modules.xml
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
Solution 7:[7]
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.
Solution 8:[8]
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
Solution 9:[9]
This worked for me:
In app/build.gradle
, remove this line from dependencies {
:
implementation project(':library')
In settings.gradle
, change
include ':app', ':library'
to
include ':app'
Then you can import the library. Be sure to put the lines back into the gradle files you took out above.
Solution 10:[10]
Those who are still seeing this issue and have already removed the module from settings.gradle
file but still sees that Module already present while importing it again, This is what I did:
1.) Switch to Project
mode in Android studio for your project
2.) Once switching it to Android
mode, delete that module manually by clicking right click on it.
And Hope it works for you now.
Solution 11:[11]
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
Solution 12:[12]
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
Solution 13:[13]
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.
Solution 14:[14]
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'
Solution 15:[15]
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.
Solution 16:[16]
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.
Solution 17:[17]
I had same issue, initially created a module, then removed it from settings.gradle and finally the fix was to ACTUALLY remove ALL folders related to that module, those won't be visible in the ANDROID view, hence change to project view and remove all related or browse using an external tool and remove all folders
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow