Android Studio (Intellij) keeps adding second line to modules.xml

855 views Asked by At

In my ~/project/.idea/modules.xml file the 8th line is always repeated. If I delete it, the line is put back whenever I save (auto-save).

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/GoogleMapsForWork/GoogleMapsForWork.iml" filepath="$PROJECT_DIR$/GoogleMapsForWork/GoogleMapsForWork.iml" />
      <module fileurl="file://$PROJECT_DIR$/SAMRecipeApplication/SAMRecipeApplication.iml" filepath="$PROJECT_DIR$/SAMRecipeApplication/SAMRecipeApplication.iml" />
      <module fileurl="file://$PROJECT_DIR$/SAMStore/SAMStore.iml" filepath="$PROJECT_DIR$/SAMStore/SAMStore.iml" />
      <module fileurl="file://$PROJECT_DIR$/SillyAppStore.iml" filepath="$PROJECT_DIR$/SillyAppStore.iml" />
      <module fileurl="file://$PROJECT_DIR$/SillyAppStore.iml" filepath="$PROJECT_DIR$/SillyAppStore.iml" />
      <module fileurl="file://$PROJECT_DIR$/SillyAppStore/SillyAppStore-SillyAppStore.iml" filepath="$PROJECT_DIR$/SillyAppStore/SillyAppStore-SillyAppStore.iml" />
      <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
      <module fileurl="file://$PROJECT_DIR$/apptentive/apptentive.iml" filepath="$PROJECT_DIR$/apptentive/apptentive.iml" />
      <module fileurl="file://$PROJECT_DIR$/volley/volley.iml" filepath="$PROJECT_DIR$/volley/volley.iml" />
    </modules>
  </component>
</project>

I understand that there's some setting somewhere that insists on doubling this line (or it's created in two places), but I don't understand the intracies of the IDE well enough to track this error down. None of my co-workers have this problem; it's stumping everyone here.

This issue has been puzzling, but hasn't prevented me from working. It does cause problems with version control as this file is ALWAYS flagged as modified (prevents me from simply typing git add -A).

Any suggestions, other than wiping the project and starting fresh?

2

There are 2 answers

1
Loyea On

It's often happens when you first time open the project, and the solution is quite simple and easy. Just delete the original line and the duplicate line, then wait few minutes for Android Studio generate it again, after re-generate, it will never duplicate later.

For your situation, delete these two repeated lines, then wait few minutes for generate again.

<module fileurl="file://$PROJECT_DIR$/SillyAppStore.iml" filepath="$PROJECT_DIR$/SillyAppStore.iml" />
<module fileurl="file://$PROJECT_DIR$/SillyAppStore.iml" filepath="$PROJECT_DIR$/SillyAppStore.iml" />
0
ris8_allo_zen0 On

This seems to have been working for me:

  1. Close Android Studio
  2. Edit modules.xml with a text editor, remove the duplicate module entries
  3. Commit
  4. Reopen Android Studio

AS shouldn't change that file now. Also, it shouldn't show warnings like "project is already loaded".