Error loading project in Android Studio: cannot load modules
Asked Answered
T

7

69

When I Checkout a project form Google Cloud, Android Studio sais: "2 modules cannot be loaded. You can remove them from the project" and I cannot see the project. The error is in the iml files app.iml and ProjectName.iml.

Thanks!

Tabaret answered 29/2, 2016 at 17:29 Comment(1)
you can't see the code? but if you checkout you have to see it no?Heavensent
L
110

Delete the *.iml files and rebuild the project (Build > Rebuild), it should be ok after that.

Lezley answered 29/2, 2016 at 17:51 Comment(6)
Android Studio automatically suggested this Solution ! +1Interchangeable
...ok, fine, but what is the solution to not get these warnings?Jala
@Jala these files are generated from the IDE and sometimes they are out of sync (i.e. you remane a module, you change dependencies). But I haven't seen this problem for a while with the newer version of android studio. I don't really have a solution since this problem was easily to fix when you rebuild the project.Lezley
Exit Android Studio, delete *.iml and .idea directory and re-import. Works for me.Kb
wow!!.. that's work for me. if I add what I did additionally, I import the project as a new one. Not from the recent project. I removed the project from the recent list.Serpigo
deleting .idea directory and then opening the project works for me.Fey
M
31

The best way to get rid of this problem is below:

1- close the project

2- close Android Studio IDE

3- delete the .idea directory

4- delete all .iml files

5- open Android Studio IDE and import the project again

Mammalogy answered 12/2, 2019 at 6:50 Comment(1)
This suggestion works for me.Fey
M
8

As was already answered here the best solution is deleting all .iml files, but it could be done just Refreshing Gradle Project at Gradle tab> right click on your project > Refresh Gradle Project.

Then a Clean and Rebuild should be done also.

Edit:

The screenshot:

enter image description here

Monzon answered 12/2, 2019 at 14:41 Comment(0)
R
7

I think you can take the IDE automatic advice of deleting the xxx.iml files

Rafaelita answered 30/6, 2017 at 2:6 Comment(1)
I did and it worked. Initially I thought the advice will make things worse but that is far from the truthTuff
D
7

Removing modules.xml file under the /.idea folder solved my issue.

Discredit answered 3/3, 2020 at 11:47 Comment(1)
underrated fixed my flutter heirarchy thanksWere
L
2

I had this issue in Android Studio 3.4 when I loaded an old project. I found some XML files in the .idea folder, including the file .idea/modules.xml.

It contained multiple <module fileurl="..."> tags, some of these were duplicates of existing modules but these had incorrect paths, in the fileurl attribute. I closed the project, deleted these duplicate tags, and reopened the project. This resolved the error for me.

Lamarckism answered 19/10, 2019 at 11:56 Comment(0)
C
1

For my Flutter project, it was not enough to delete the .idea directory in the project root, I had to delete also .idea folder in android directory.

1- close the project

2- close Android Studio IDE

3- delete the .idea directory, but also android/.idea directory!

4- delete all .iml files

5- open Android Studio IDE and reopen project

That's it, happy coding.

Cirrostratus answered 11/3, 2021 at 21:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.