Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be in my .gitignore for an Android Studio project?

What files should be in my .gitignore for an Android Studio project?

I've seen several examples that all include .iml but IntelliJ docs say that .iml must be included in your source control.

like image 618
respectTheCode Avatar asked May 24 '13 14:05

respectTheCode


People also ask

What should be in my Gitignore file?

gitignore should list the names or name-patterns of files that will be found in work-trees when working with your project, but that should not be committed to the project. In other words, it's not OS-specific, it's project-specific.

Should gradle files be in Gitignore?

Gradle compiles java files and generates class files in the target folder.so These files add to gitignore. The archive files created by the final application are in the jar, ear, and war formats. The following entries add to the gitignore file for package-related files.

How do I use .gitignore file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.


1 Answers

Updated to Android Studio 3.0 Please share missing items in comments.

A late answer but this alternative answer was not right for us ...

So, here's our gitignore file:

#built application files *.apk *.ap_ *.aab                             # 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                              # Android Studio *.iml .idea #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. .gradle build/ .navigation captures/ output.json       #NDK obj/ .externalNativeBuild 

Since Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:

*.iml .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures .externalNativeBuild 

Deprecated - for older project format, add this section to your gitignore file:

 /*/out /*/*/build /*/*/production *.iws *.ipr *~ *.swp 

This file should be located in the project's root folder and not inside the project's module folder.

Edit Notes:

  1. Since version 0.3+ it seems you can commit and push *.iml and build.gradle files. If your project is based on Gradle: in the new open/import dialog, you should check the "use auto import" checkbox and mark the "use default gradle wrapper (recommended)" radio button. All paths are now relative as @George suggested.

  2. Updated answer according to @128KB attached source and @Skela suggestions

like image 105
Lior Iluz Avatar answered Sep 28 '22 12:09

Lior Iluz