I have accidentally erased one of my project modules .iml file and I was wondering if its possible to regenerate it. I have googled around for a bit but I have not seen a solution yet.
-
2if you have not closed intellij since, locate the folder it used to be in > right click > Local history > show history. from here you should be able to restore that iml file. – petey Dec 17 '14 at 19:04
-
@petey dude that worked thank you :) You should have made that an answer – James andresakis Dec 17 '14 at 19:31
-
Not sure why Scott Barta's answer did not work. Should have. Perhaps it needed a re-import after the file recovery. – petey Dec 17 '14 at 19:53
8 Answers
If your project is Gradle-based, then click the Sync Project with Gradle Files button in the toolbar and it will regenerate all .iml files.
If you can't locate this button , then just look at right for Gradle tasks -> select task -> right click -> refresh external dependency will bring you back modules and iml file.

- 1
- 1

- 79,344
- 24
- 180
- 163
-
3I tried that but it didnt work for me. Maybe its possible that I have to many modules (9 at this time). – James andresakis Dec 17 '14 at 19:32
-
2It also works with Maven. Just click the `Reimport All maven Projects` button and it should work the same way. – dadus33 Jul 18 '17 at 15:13
-
1This should be the right anwser. iml files are gitignored by default, gradle sync will regenerate the file. – wrkwrk Nov 28 '18 at 03:35
-
1
-
1@IgorGanapolsky It now looks like a grey elephant (gradle logo) with a blue arrow pointing down and to the left. It's in the top right of the toolbar. – Lenny Dec 04 '19 at 00:51
If you have not invalidated your cache or updated intellij since, locate the folder it used to be in > right click > Local history > show history. from here you should be able to restore that .iml
file
Reimport the module (our project is maven-based, but that shouldn't matter).
Go to file -> project structures -> modules -> import module (click the +)
Then simply select your module and click through the wizard.

- 686
- 6
- 6
IntelliJ generates the .iml
files for you.
I struggled with this issue until I noticed that for some reason the pom files of these modules appear under ignored files list.
To remove those files from this list, go to:
Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Ignored Files.
And uncheck your modules!

- 10,019
- 9
- 74
- 96

- 51
- 4
I solved the problem as follows: 1) Opened the IntelliJ IDEA 2) Selected menu point "import project" 3) Navigated to the folder containing my project 4) Imported the project (in my case as maven project) and builded it new.

- 1,839
- 19
- 14
In my case i deleted the .iml
files manually and the project structure was not showing up. I just closed the intelliJ and when i opened it back, i got a notification window indicating that Non-manged pom.xml file found
. and when i selected "Add as Maven Project" in the notification window, the project structure was back again.

- 3,896
- 5
- 30
- 44
Find your gradle
tab on one of your shortcut bars (I think by default it is on the vertical toolbar on the right of android studio). Click on it and you will see your gradle structure in the opened tab.
On top of that tab, you can see a refresh icon. Click on it and it will reconstruct all your iml files.
The solution of retrieving the deleted files might work if you work on your own, but if you have fetched someone elses config, you need to recreate your own imls for your local configuration.

- 335
- 5
- 5