什么文件应该在我的。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

其他回答

我合并Github .gitignore文件

Android.gitignore JetBrains.gitignore

### Github Android.gitignore ### 

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

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

### Github JetBrains.gitignore ### 

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

请阅读:JetBrains支持:如何在版本控制系统下管理项目

编译:

#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 0.8.4开始,启动新项目时自动生成gitignore文件。默认情况下,它包含:

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

我同意这个说法,但是我修改了这个文件来改变 /建造到建造/ (包括/build和/app/build) 这样我就不会把所有的文件都放在app/build中。

还要注意,如果从Eclipse导入项目,.gitignore不会被复制,也不会“自动地”为您创建。

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

你有两个选择:

基于目录的格式(您将有一个.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

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

# Keystore files
*.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

安卓Gitignore在github