什么文件应该在我的。gitignore为一个Android工作室项目?

我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。


当前回答

https://github.com/github/gitignore是很棒的收藏

Android.gitignore

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

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

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

其他回答

我的建议是不要忽略。idea文件夹。

我已经将一个基于git的Eclipse项目导入到Android Studio,效果很好。后来,我想用Git导入这个项目(就像第一次一样)到另一台带有Android Studio的机器上,但没有成功。Android Studio确实加载了所有文件,但无法将项目“视为”项目。我只能打开Git-files。

当第一次导入项目(从Eclipse到Android Studio)时,我的旧的.gitignore被覆盖了,新的看起来像这样:

.idea / . name .idea / compiler.xml .idea /版权/ profiles_settings.xml .idea / encodings.xml .idea /图书馆/ libs.xml .idea / misc.xml .idea / modules.xml .idea /范围/ scope_settings.xml .idea / vcs.xml .idea / workspace.xml

所以,我试着用一个空的gitignore,现在它工作了。另一个Android Studio可以加载文件和项目。我猜有些文件对于Git和导入来说并不重要(profiles_settings.xml),但我很高兴它起作用了。

取决于你的项目格式是如何维护的:

你有两个选择:

基于目录的格式(您将有一个.idea文件夹,其中包含 项目特定文件) 基于文件的格式(配置文件为。iws和。ipr)

裁判: http://www.jetbrains.com/idea/webhelp/project.html

提交给版本控制的文件依赖于上述:

包括。idea文件夹到版本控制,排除workspace.xml和 tasks.xml 版本控制的.ipr文件和所有的.iml模块文件,排除 iws文件,因为它存储了用户特定的设置。

裁判: https://intellij-support.jetbrains.com/entries/23393067

使用Android Studio 3.0测试

你可能需要安装.ignore插件。

你可以为Android自动生成.gitignore文件。 右键单击文件夹并跟随

然后从左侧面板选择Android,单击Generate

Android Studio将生成.gitignore文件,其中包含所有需要忽略的文件。

摘自http://menukanows.com/how-to-add-gitignore-file-in-android-project/

编译:

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Gradle files
.gradle/
build/
/*/build/

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

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# 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/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

在Android Studio中,唯一需要保存在版本控制中的文件是使用gradle从命令行构建应用程序所需的文件。所以你可以忽略:

* .iml .idea 构建

但是,如果您保存任何IDE设置,例如自定义代码样式设置,它们将保存在.idea文件夹中。如果您希望在版本控制中进行这些更改,那么您也可以保存IDEA文件(*。Iml和idea)。