Reputation: 1070
I'm using Android Studio 0.3.0 (configured to use gradle wrapper to build), Gradle 1.8. Everytime I build (or rebuild) the project with Android Studio, I get the error:
Gradle: A problem occurred evaluating project ':MyProject'.
> For input string: ""
Clicking on the error, here is the error code in build.gradle:
def getCommitsCount() {
return 'git rev-list --count HEAD'.execute().text.toInteger()
}
If I remove .toInteger()
then the error is gone. Otherwise, I can build the project from console just fine ./gradlew clean check build
.
Anyone is getting the same problem? It seems to be a problem of Android Studio. If you know any workaround or fix, that would be cool.
Upvotes: 6
Views: 4282
Reputation: 1295
My problem was that I didn't have a Xcode version selected.
You can also try reinstalling Xcode Command Line Tools: xcode-select --install
Upvotes: 0
Reputation: 30865
To find out what is the reason that output stream is empty access the error stream using err
.
def getCommitsCountError() {
return 'git rev-list --count HEAD'.execute().err.text.toInteger()
}
Is likely as JChord pointed that error can be.
"xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun"
Then the solution is to (re)install Xcode Command Line Tools.
xcode-select --install
Upvotes: 3
Reputation: 128
Perhaps you've removed the xcode causes the issuse. Try to reinstall Command Line Tools to make sure the git work normal.
run as below command:
xcode-select --install
Click “Install” to download and install Xcode Command Line Tools.
Upvotes: 1
Reputation: 1529
I had the same issue with getting the commit count. What worked for me finally was
def getGitCommitCount() {
def process = "git rev-list HEAD --first-parent --count".execute()
return process.text.toInteger()
}
Upvotes: 0
Reputation: 1070
I think Android Studio run "make" from a different directory, so here is my fix and it works as expected:
def getCommitsCount() {
return "git --git-dir=${projectDir}/.git --work-tree=${projectDir} rev-list --count HEAD".execute().text.toInteger()
}
Upvotes: 0