Is it mandatory to save *.iml files in Version control?

I have now switched to Android Studio and saving my projects in Git with Source Tree. Whenever I add or remove any library from my module, its .iml file also changes. It really doesn't matter if I commit the *.iml because they get auto-generated in others Android Studio. However, here it says you should store *.iml . My question is, do we really need to share our *.iml with others? If yes, why?


General best practice is to:

  • make projects as IDE-agnostic as possible,
  • do not commit generated files.

So the answer is: it's better to make such files ignored for VCS.


Yes, .iml Files are suitable for version control (see this comment)

It is also true to make projects as IDE-agnostic as possible, however, sharing .iml files does not break anything for people developing with another IDE. For them, they are just a bunch of relatively small files that don't concern them.

A good practice for teams using different IDEs simultaneously is to store each IDE's project files in the VCS, only excluding those which contain paths, environment variables etc. specific to a single developers environment. This way, anyone using one of the supported IDEs can enjoy the benefits of a proper, shared setup, like for example:

  • sharing build configurations
  • sharing dependencies
  • configurations for automatic code quality checks

There are more use cases, depending on the specific IDEs in play. Edit: For IntelliJ, also see this FAQ


I agree that they are IDE-dependant files irrelevant to code and they should not be shared. But, then you should know how to regenerate them.

You may encounter with situations while your remote repo does not contain these files and when you clone the code and open in IDEA, it just shows a bunch of errors. Why? *.iml files are not regenerated.

You must import from IDEA with "File" - "New" - "Project from Version control". Only this can generated the files for you.