我遇到源控制问题,在使用gradle同步项目后,某些文件会不断更改。
这是通常发生的事情
git status
modified: app/build/generated/source/r/debug/android/support/v7/appcompat/R.java
modified: app/build/generated/source/r/debug/com/google/android/gms/R.java
modified: app/build/generated/source/r/debug/obfuscated/obfuscated/R.java
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$color.class
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$drawable.class
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$id.class
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$layout.class
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$string.class
deleted: app/build/intermediates/classes/debug/com/google/android/gms/R$color.class
deleted: app/build/intermediates/classes/debug/com/google/android/gms/R$drawable.class
deleted: app/build/intermediates/classes/debug/com/google/android/gms/R$string.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/Globals.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$color.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$dimen.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$drawable.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$id.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$integer.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$layout.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$menu.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$mipmap.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$raw.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$string.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$style.class
deleted: app/build/intermediates/classes/debug/obfuscated/obfuscated/R$styleable.class
modified: app/build/intermediates/manifests/full/debug/AndroidManifest.xml
modified: app/build/intermediates/symbols/debug/R.txt
我已经与团队的其他成员联系,使用了这个.gitignore:
#built application files
*.apk
*.ap_
# 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
# Eclipse project files
.classpath
.project
# Android Studio
*.iws
*.iml
.idea
.gradle
build/
*/build/
问题1:提交上述更改吗?
这些文件都与.gitignore中指定的*/build/
匹配,因此我的本能是使用git rm
在本地删除它们。这是对的吗?
问题2:删除清单或整个构建文件夹是否存在问题?
这一个:app/build/intermediates/manifests/full/debug/AndroidManifest.xml
删除整个构建文件夹(git rm app/build -r -f
)并重新同步会产生此错误:
Error:Execution failed for task ':app:processDebugManifest'. > com.android.manifmerger.ManifestMerger2$MergeFailureException: java.io.FileNotFoundException: /Users/Obfuscated/Projects/Android/Obfuscated/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/AndroidManifest.xml (No such file or directory)
问题3:如何正确组织项目和团队?
我需要做什么才能正确组织项目?我的团队其他成员将如何进行?
答案 0 :(得分:2)
在尝试之前备份您的文件。
你有两个问题。
问题1的解决方案:
删除构建文件夹。它是由渐变产生的。
来自git status的行
deleted: app/build/intermediates/classes/debug/android/support/v7/appcompat/R$color.class
表示已在工作副本上删除了Git存储库中提交的文件,这很好。所以,是的,你确实想提交这个'删除'。
问题2的解决方案: 在步骤1之后,从Git存储库中删除不需要的文件。 Git Status将显示“添加”文件列表。修改.gitignore文件,使其不再显示在git status命令中。像/ build / **这样的东西,你需要调整它。通常,/ build中的文件不应提交给Git存储库
根据需要重复
作为任何git add命令之前的一般规则,请考虑这是否正确或是否应包含在.gitignore中
Manifest文件应该提交给git存储库。但不是build文件夹中的那个。