27

In our project, we have committed .idea/codeStyles/Project.xml to source control with the goal of enforcing a common style among all contributors to the project without affecting the style of other projects.

However, Android Studio appears to be making unwanted changes to this file.

Pulling down the latest code from git and then simply opening Android Studio and then checking git status produces:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   my-project/.idea/codeStyles/Project.xml

no changes added to commit (use "git add" and/or "git commit -a")

The changes it is making look like this: enter image description here

As you can see it is removing some XML-formatting settings.

I am running Android Studio 3.5, but I can't guarantee that everyone else is, and we would like to keep the project agnostic with respect to IDE-version.

Is there a way to prevent Android Studio from changing these settings? Is there a more recommended way to achieve uniform code-style?

duggulous
  • 2,427
  • 3
  • 23
  • 40
  • Are these changes to the Project.xml causing changes in how your code is formatted? There's a chance the options that are removed from the config file are options where the configured value matches the default. In that case you should be good to commit the changes with no impact on your project. – Damien Diehl Dec 09 '19 at 17:23
  • 1
    I recommend going through and systematically disabling any non-standard / default plugins you may have loaded in Android Studio. In my case a plugin (Markdown Navigator Enhanced) was editing the Project.xml. Once I disabled that plugin for good, the file was no longer being modified. You may find options in the offending plugin you can play with to stop that behavior as well. – CzarMatt Apr 02 '20 at 17:45
  • We haven't added any plugins on top of what comes bundled with Android Studio – duggulous Apr 07 '20 at 18:41
  • @CzarMatt thanks a lot, it was my case :) one of the installed plugins, Database Navigator, kept modifying the file. Disabling it fixed it. – untosabla Apr 21 '20 at 13:34
  • I have the same issue. It stoped for a while after reimporting the project but now it is at it again. I don't have any plugins. – Pol Apr 27 '21 at 16:50

0 Answers0