Error loading project in Android Studio: cannot load modules

AndroidAndroid Studio

Android Problem Overview

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.


Android Solutions

Solution 1 - Android

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

Solution 2 - Android

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

Solution 3 - Android

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

Solution 4 - Android

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

Solution 5 - Android

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.


The screenshot:

enter image description here

Solution 6 - Android

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.

Solution 7 - Android

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.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFederico BlumettoView Question on Stackoverflow
Solution 1 - AndroidxiaomiView Answer on Stackoverflow
Solution 2 - AndroidKaushal KishorView Answer on Stackoverflow
Solution 3 - AndroidCan UludağView Answer on Stackoverflow
Solution 4 - AndroidBarry LiuView Answer on Stackoverflow
Solution 5 - Androiduser3113001View Answer on Stackoverflow
Solution 6 - Androidgregn3View Answer on Stackoverflow
Solution 7 - AndroidmilossView Answer on Stackoverflow