对于 Android Studio 项目,我的 .gitignore 中应该包含哪些内容? [英] What should be in my .gitignore for an Android Studio project?

查看:41
本文介绍了对于 Android Studio 项目,我的 .gitignore 中应该包含哪些内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Studio 项目的 .gitignore 中应该包含哪些文件?

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

我见过几个都包含 .iml 的示例,但 IntelliJ 文档说 .iml 必须包含在您的源代码管理中.

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

推荐答案

更新至 Android Studio 3.0请在评论中分享缺失的项目.

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

一个迟到的答案但是这个 替代答案不适合我们......

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

所以,这是我们的 gitignore 文件:

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

从 Android Studio 2.2 到 3.0,新项目都是用这个 gitignore 文件创建的:

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

已弃用 - 对于较旧的项目格式,将此部分添加到您的 gitignore 文件中:

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.

编辑备注:

  1. 从 0.3+ 版本开始,您似乎可以提交和推送 *.imlbuild.gradle 文件.如果您的项目基于 Gradle:在新的打开/导入对话框中,您应该选中 使用自动导入" 复选框并标记 使用默认 gradle 包装器(推荐)"; 单选按钮.正如@George 建议的那样,所有路径现在都是相对的.

  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.

根据@128KB 附件来源和@更新了答案Skela 建议

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

这篇关于对于 Android Studio 项目,我的 .gitignore 中应该包含哪些内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆