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

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


当前回答

Android Studio 3.5.3

我在我的库和项目中使用这个,它涵盖了大多数由android studio和其他著名工具生成的文件:

# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Generated files
bin/
gen/
out/
app/release/

# Gradle files
.gradle/
build/

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

# 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 lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

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

# Freeline
freeline.py
freeline/
freeline_project_description.json

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

#NDK
*.so

其他回答

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),但我很高兴它起作用了。

我不同意所有这些答案。下面的配置非常适合我们组织的应用程序。

我忽略:

/构建 /。想法(可能有例外,见dalewking回答中的评论) * .iml local.properties

我想几乎每个人都同意/建造。

我厌倦了经常看到关于Gradle在/.idea中创建或删除的各种library.xml文件的消息。构建。当开发人员第一次签出项目时,gradle将在他们的本地运行,那么为什么这些XML文件需要版本控制呢?Android Studio也会生成/的剩余部分。当开发人员使用版本控制签出创建项目时,为什么该文件夹中的任何东西都需要进行版本控制?

如果*。Iml的版本是一个新用户将必须命名项目完全相同,当它被提交。既然这也是一个生成的文件,那么为什么首先要为它设置版本呢?

当地的。properties文件指向SDK文件系统上的绝对路径,因此绝对不应该对其进行版本控制。

编辑1:添加.gradle来忽略gradle缓存不应该被版本化的东西(感谢Vasily Makarov)。

编辑2:添加. ds_store现在我使用Mac。这个文件夹是Mac特定的,不应该被版本化。

另外注意:在构建发布版本时,您可能还想添加一个目录来放置签名密钥。

为方便复制/粘贴:

.gradle
/build
/.idea
*.iml
local.properties
.DS_Store 

从Android Studio 0.8.4开始,启动新项目时自动生成gitignore文件。 默认情况下,它包含:

.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build

我用这个。gitignore。我在http://th4t.net/android-studio-gitignore.html找到了它

*.iml
*.iws
*.ipr
.idea/
.gradle/
local.properties

*/build/

*~
*.swp