什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
当前回答
我是kosher添加。iml文件和Intellij sez添加。idea文件夹,但忽略。idea/workspace.xml和。idea/tasks.xml,但。idea/libraries/呢?
我不明白加这个有什么意义。它有一个XML文件列表,列出了Android Studio项目应该知道的库。这些应该来自于构建。gradle定义的依赖项——不是IDE项目文件。
其中一个文件的内容是这样的:
<component name="libraryTable">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-26/filestore/com.example/example/etc...jar!"/>
这样做没有意义。如果用户为gradle指定了不同的主目录,或者如果他们使用了不同的gradle版本,.gradle/caches/artifacts-xxx下的路径对他们来说将是不同的(即工件-在末尾追加的数字将与您正在使用的gradle版本发布相关)。这些路径不是通用的,但建议是检查所有这些?
其他回答
我不同意所有这些答案。下面的配置非常适合我们组织的应用程序。
我忽略:
/构建 /。想法(可能有例外,见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
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
我支持提交。idea文件夹(不包括workspace.xml和tasks.xml)。但我开始得出结论,.iml文件应该被忽略。
问题在于:
例如,在名为“foo”的目录下打开一个项目,你将得到foo。我和那一切看起来都很好。问题是,如果我只是将目录重命名为foo2(或克隆为另一个目录名),当你尝试在Android Studio中打开项目时,你会得到三件事:
一个名为foo2.iml的新iml文件 你的Android项目的iml文件将被更改为指向foo2作为它的父文件 .idea/modules.xml将为foo2添加一行。它既有旧的Iml文件,也有新目录的Iml文件
我找不到方法来阻止Android工作室做这个iml文件生成时,项目存储在一个不同的目录。将它们添加到源代码控制中会导致问题。因此,我认为也许我们应该忽略*。Iml文件和。idea/modules.xml
使用gitignore提供的api。Io,你可以得到的是自动生成的。这里是gitignore.io/api/androidstudio的直接链接
### AndroidStudio ###
# Covers files to be ignored for android development using Android Studio.
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle
.gradle/
build/
# Signing files
.signing/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio
/*/build/
/*/local.properties
/*/out
/*/*/build
/*/*/production
captures/
.navigation/
*.ipr
*~
*.swp
# Android Patch
gen-external-apklibs
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# NDK
obj/
# IntelliJ IDEA
*.iml
*.iws
/out/
# User-specific configurations
.idea/caches/
.idea/libraries/
.idea/shelf/
.idea/workspace.xml
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/assetWizardSettings.xml
# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Legacy Eclipse project files
.classpath
.project
.cproject
.settings/
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
hs_err_pid*
## Plugin-specific files:
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Mongo Explorer plugin
.idea/mongoSettings.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### AndroidStudio Patch ###
!/gradle/wrapper/gradle-wrapper.jar
# End of https://www.gitignore.io/api/androidstudio
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