2

I am working on a project from two different computers, both running Windows 8.1 and Android Studio 0.5.1. Every time I build the app on a different PC, Android Studio makes changes to some of the config files which are tracked by git.

For instance, .idea/misc.xml:

- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">

(- and + at the beginning of the lines represent removed and added lines)

MyProject.iml:

- <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
+ <orderEntry type="jdk" jdkName="Android SDK" jdkType="Android SDK" />

I'm under the impression that these two files should be tracked by version control, so why are the different machines making changes to it every time I load the project? I can't find any setting that would affect this.

Ellis
  • 3,048
  • 2
  • 17
  • 28

1 Answers1

0

If your project is Gradle-based, then it's intended that you not check in anything in .idea or any of the .iml files into source control; the Gradle build files are the sole source of truth.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • 3
    When I looked there seemed to be no agreed answer: http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project, https://intellij-support.jetbrains.com/entries/23393067 I followed the 2nd link (check in all files under .idea directory except workspace.xml and tasks.xml), assuming that it also applied to Gradle (which I am using) in Android Studio. One comment from 1st link: "do not ignore .idea folder for now. Gradle plugin doesn't have any 'gradle idea' task yet and import project in Android Studio is far from perfect now" Has this changed? – Ellis Mar 14 '14 at 22:19
  • Uhm, gradle _does_ have an `"idea"` module... And IDEA is able to import gradle project reliably, at least starting with 13.x. Don't use gradle 1.11 for now though, 13.0.x doesn't handle it correctly. 13.1 will when it's out – fge Mar 14 '14 at 22:23
  • @Ellis -- the SO question is about Android Studio and is correct; the link to IJ-support is for IntelliJ, not Android Studio. Android Studio uses its Gradle build files as the source of truth for project structure; the fact that it generates .iml and .idea files and folders is an (unfortunately very visible and very confusing) implementation detail. – Scott Barta Mar 14 '14 at 22:26
  • When you say the question is correct, do you mean the accepted answer? This also has an edit saying: 'Since version 0.3+ it seems you can commit and push *.iml and build.gradle files'. Lots of different opinions floating around in the answers and comments there. – Ellis Mar 14 '14 at 22:29
  • I agree with @ScottBarta, you should `.gitignore` the `.idea` folder and all iml files; IDEA will know how to generate these out of gradle files, so don't bother – fge Mar 14 '14 at 22:38
  • Thanks, I'm going to try this. I'll double check it on Monday when I'm back at my other PC and mark this answer as accepted if it's working. – Ellis Mar 15 '14 at 00:11
  • 1
    I'm not sure this is necessarily the ideal solution for every project and going forward (some files like the copyright info might be useful for teams to keep in a VCS) but I think it's the best solution for me, now, so I'm marking it as accepted. Thanks! – Ellis Mar 17 '14 at 10:41
  • It's strange. When we create a new project, gitignore files are created by android studio and does not contain .iml files and not all .idea file ... – mrroboaat Dec 27 '14 at 14:46
  • There are issues with projects that use gradle wrapper and needing to check in some .idea files (as horrible as that is, that is the way you must do it to not have gradle wrapper issues, at least pre-AS-1.0, haven't tried to see if that version and the associated gradle plugin fix the issue) – Colin M. Jan 15 '15 at 23:50