Federico Blumetto
Federico Blumetto

Reputation: 977

Error loading project in Android Studio: cannot load modules

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!

Upvotes: 70

Views: 74811

Answers (7)

Kaushal Kishor
Kaushal Kishor

Reputation: 481

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

Upvotes: 34

miloss
miloss

Reputation: 1768

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.

Upvotes: 1

Can Uludağ
Can Uludağ

Reputation: 715

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

Upvotes: 8

gregn3
gregn3

Reputation: 1774

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.

Upvotes: 2

user3113001
user3113001

Reputation: 111

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

Upvotes: 9

Barry Liu
Barry Liu

Reputation: 97

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

Upvotes: 7

xiaomi
xiaomi

Reputation: 6703

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

Upvotes: 115

Related Questions