问题描述
我已经安装我的Android Studio项目与Github上工作。这是我的Manifext
I've setup my Android Studio Project to work with Github. Here is my Manifext
apply plugin: 'com.android.application'
def gitVersion() {
def counter = 0
def process = "git rev-list master --first-parent --count".execute()
counter = process.text.toInteger()
return counter
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
def versionMajor = 0
def versionMinor = 1
def versionPatch = 0
defaultConfig {
applicationId "com.my.packagename"
minSdkVersion 15
targetSdkVersion 20
versionCode gitVersion()
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
然而,当我使用gitVersion()我得到以下错误,
However, when I use gitVersion() I get the following error,
Error:(7, 0) For input string: ""
对我来说,这意味着进程正在返回一个空字符串。但是,我能够从我的命令行运行这一点,并得到预期的结果。
To me, this means that process is being returned an empty string. However, I am able to run this from my command line and get the expected result.
这是怎么回事就在Android的工作室?
Why is this happening just in Android Studio?
推荐答案
我发现这个问题。 Android的工作室在执行默认情况下,项目文件夹命令行操作。我做了我的项目,这样的混帐回购协议里面住着我的应用程序目录,而不是在我的项目目录,所以在项目层面的任何Git命令会出错,因为它不知道的git仓库一个目录下来。
I found the problem. Android studio performs command line operations in the project folder by default. I had made my project such that the git repo lived inside my app directory instead of in my project directory, so any git commands on the project level would error, since it didn't know about the git repo one directory down.
我的解决办法是为动我的git回购出来的应用程序目录,进入项目目录。有一次,我做到了,剧本的工作完美。
My solution was to move my git repo out of the app directory and into the project directory. Once I did that, the script worked perfectly.
这篇关于Git的REV-列表不工作在Android的工作室build.gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!