Updated to Android Studio 3.0 Please share missing items in comments.
(更新至Android Studio 3.0。请分享评论中缺少的内容。)
A late answer but none of the answers here and here was right on the money for us...
(答案很晚,但这里和这里的答案都不对,这对我们来说是钱...)
So, here's our gitignore file:
(因此,这是我们的gitignore文件:)
#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
# 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:
(从Android Studio 2.2及更高版本开始,使用gitignore文件创建新项目:)
*.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:
(不推荐使用 -对于较旧的项目格式,请将此部分添加到您的gitignore文件中:)
/*/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:
(编辑注释:)
Since version 0.3+ it seems you can commit and push *.iml and build.gradle files.
(从0.3+版本开始,您似乎可以提交并推送* .iml和build.gradle文件。)
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. (如果您的项目基于Gradle:在新的打开/导入对话框中,则应选中"use auto import"
复选框,并标记"use default gradle wrapper (recommended)"
单选按钮。)
All paths are now relative as @George suggested. (现在所有路径都是相对的,如@George所建议。)
Updated answer according to @128KB attached source and @Skela suggestions
(根据@ 128KB 附件来源和@Skela建议更新了答案)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…