Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files to exclude from GIT for Android Studio Gradle Project to maintain the code in MAC as well as Windows.?

I code in MAC - OSX and my partner codes in PC - Windows but when I commit and push changes there are multiple files in project directories ending with .IML or .config or .properties, which gets overwritten and cause frequent overwrites which is a nuisance.

So my question is which files can be excluded from GIT for Android Studio Gradle Project to maintain the code in MAC as well as Windows? and what is the best way to do it ?

like image 996
Gowrav Avatar asked Sep 19 '16 18:09

Gowrav


People also ask

Which type of file should be tracked by Git?

Tracked files are files that were in the last snapshot, as well as any newly staged files; they can be unmodified, modified, or staged. In short, tracked files are files that Git knows about.

Where are Gradle dependencies stored?

Where are dependencies stored in Gradle project? The Gradle dependency cache consists of two storage types located under GRADLE_USER_HOME/caches : A file-based store of downloaded artifacts, including binaries like jars as well as raw downloaded meta-data like POM files and Ivy files.

Where do I put repositories in Android Studio?

Go to buildscript > repositories and configure the Maven repository address for the HMS Core SDK. If the agconnect-services. json file has been added to the app, go to buildscript > dependencies and add the AppGallery Connect plugin configuration and Android Gradle plugin configuration.


1 Answers

Here is a decent .gitignore file which you put in the root directory of your project, e.g. the folder where the .git folder is:

#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
*.iml
.idea/
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle/
build/

app/build/

gradle/

#NDK
obj/

Then you execute the following commands to apply the .gitignore:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

See more here.

EDIT: I also recommend using the .gitignore plugin for Android Studio.

like image 116
azurh Avatar answered Oct 31 '22 09:10

azurh