Can you regenerate a deleted modules .iml file in android studio
Asked Answered
J

8

50

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.

Joellajoelle answered 17/12, 2014 at 19:0 Comment(3)
if 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.Felicio
@Felicio dude that worked thank you :) You should have made that an answerJoellajoelle
Not sure why Scott Barta's answer did not work. Should have. Perhaps it needed a re-import after the file recovery.Felicio
F
48

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

Felicio answered 17/12, 2014 at 19:53 Comment(1)
The closing part didn't matter for me. It worked the same way.Luxembourg
A
79

If your project is Gradle-based, then click the Sync Project with Gradle Files button enter image description here 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.

Adaptive answered 17/12, 2014 at 19:7 Comment(5)
I tried that but it didnt work for me. Maybe its possible that I have to many modules (9 at this time).Joellajoelle
It also works with Maven. Just click the Reimport All maven Projects button and it should work the same way.Flighty
This should be the right anwser. iml files are gitignored by default, gradle sync will regenerate the file.Luiseluiza
There is no such button in A.S.Flickertail
@Flickertail 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.Cenesthesia
F
48

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

Felicio answered 17/12, 2014 at 19:53 Comment(1)
The closing part didn't matter for me. It worked the same way.Luxembourg
K
44

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.

Keary answered 11/3, 2016 at 13:16 Comment(0)
S
4

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!

Snicker answered 30/10, 2016 at 13:29 Comment(2)
nice one! thank a lot. that is a real pain in the IntelliJPalpitation
Is maven in Android Studio?Flickertail
S
3

Right-click on the pom.xml, -> maven -> reimport (intellij)

Semiyearly answered 1/8, 2018 at 10:31 Comment(1)
Android uses pom.xml?Flickertail
M
1

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.

Mg answered 20/2, 2018 at 15:24 Comment(0)
T
1

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.

Theis answered 4/4, 2018 at 20:49 Comment(0)
Q
0

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.

Quadriplegic answered 7/11, 2017 at 9:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.