kraftydevil
kraftydevil

Reputation: 5246

Android Studio: SDK location changes for same project using Mac (OSX) and Windows

I am working on an Android Studio project where my team members use Windows and I use OSX.

The problem is that when I pull new code from git and then open the project, I get all sorts of changes based on the Mac's SDK location:

First a notice when opening the project: enter image description here

git diff logs a bunch of changes similar to this one:

enter image description here

How do we configure the Android Studio project so that these automatic code changes do not have to occur, or maybe there is a way to minimize the number of files changed?

Update:

I updated the .gitignore and pushed it to the remote repo.

When my team updated more code and I pulled it, I still got the same issues.

Here is a snippet of my git status after pulling (I used "..." to denote multiple files from that folder):

modified:   .idea/gradle.xml
modified:   .idea/misc.xml
modified:   .idea/modules.xml
modified:   .idea/vcs.xml
modified:   app/app.iml
modified:   app/build/intermediates/incremental/mergeAssets/androidTest/debug/merger.xml
…
    modified:   app/build/intermediates/incremental/mergeResources/debug/merger.xml
    modified:   app/build/intermediates/res/debug/anim/abc_fade_in.xml
...
    modified:   app/build/intermediates/res/debug/anim/abc_slide_out_top.xml
    modified:   app/build/intermediates/res/debug/color-v11/abc_background_cache_hint_selector_material_dark.xml
    modified:   app/build/intermediates/res/debug/color-v11/abc_background_cache_hint_selector_material_light.xml
    modified:   app/build/intermediates/res/debug/color/abc_background_cache_hint_selector_material_dark.xml
...
    modified:   app/build/intermediates/res/debug/color/wallet_secondary_text_holo_dark.xml
    modified:   app/build/intermediates/res/debug/drawable/abc_btn_borderless_material.xml
...
    modified:   app/build/intermediates/res/debug/drawable/timeline_button_hover.xml
    modified:   app/build/intermediates/res/debug/layout/abc_action_bar_title_item.xml
...
    modified:   app/build/intermediates/res/debug/layout/support_simple_spinner_dropdown_item.xml
    modified:   app/build/intermediates/res/debug/menu/menu_all_locations.xml
    modified:   app/build/intermediates/res/debug/menu/menu_main.xml
    modified:   app/build/intermediates/res/debug/values-af/values-af.xml
...
    modified:   app/build/intermediates/res/debug/values/values.xml
    modified:   app/build/intermediates/resources/resources-debug-androidTest.ap_
    modified:   app/build/intermediates/resources/resources-debug.ap_
    modified:   build/intermediates/gradle_project_sync_data.bin
    modified:   local.properties

Here is my .gitignore, as suggested by @Gabriele Mariotti:

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Eclipse project files
.classpath
.project

# Android Studio
*.iws
*.iml
.idea
.gradle
build/
*/build/

Do I need additional .gitignore configurations? If I'm excluding .idea then why are these files showing up as changed?

Upvotes: 3

Views: 2328

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364471

Inside the project you will find some Android Studio files, for example the .idea and the iml files inside each module.
Check also this answer for more details.

These resources contain local paths and references and you should exclude them (the .idea folder and iml files) from your git repo.

It is an example of .gitignore we are using with Mac, Linux and Windows users.

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Eclipse project files
.classpath
.project

# Android Studio
*.iws
*.iml
.idea
.gradle
build/
*/build/

If these files are in git repo, you should remove them from the remote repo, and then rebuild the local projects.

Upvotes: 5

Related Questions