使用過Android Studio(搖籃):看看這個博客帖子:http://blog.android-develop.com/2014/09/automatic-versioning-and-increment.html
下面是從實現博客:
android {
defaultConfig {
...
// Fetch the version according to git latest tag and "how far are we from last tag"
def longVersionName = "git -C ${rootDir} describe --tags --long".execute().text.trim()
def (fullVersionTag, versionBuild, gitSha) = longVersionName.tokenize('-')
def(versionMajor, versionMinor, versionPatch) = fullVersionTag.tokenize('.')
// Set the version name
versionName "$versionMajor.$versionMinor.$versionPatch($versionBuild)"
// Turn the version name into a version code
versionCode versionMajor.toInteger() * 100000 +
versionMinor.toInteger() * 10000 +
versionPatch.toInteger() * 1000 +
versionBuild.toInteger()
// Friendly print the version output to the Gradle console
printf("\n--------" + "VERSION DATA--------" + "\n" + "- CODE: " + versionCode + "\n" +
"- NAME: " + versionName + "\n----------------------------\n")
...
}
問題不夠清楚。請多解釋一下。 – AndroidLad
您能否詳細說明一下:您檢出項目並運行「gradle」。您是否按照自述文件(克隆,子模塊,屬性)中的步驟操作?你指定的命令似乎在[此gradle文件](https://github.com/card-io/card.io-Android-source/blob/master/card.io/build.gradle) – Kariem
我只是無法導入項目的項目。它仍然在說「沒有這樣的文件或目錄」 –