使用过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
我只是无法导入项目的项目。它仍然在说“没有这样的文件或目录” –