Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not build Gradle project with Android Studio

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.

like image 301
Hieu Rocker Avatar asked Oct 20 '22 22:10

Hieu Rocker


1 Answers

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

as git is connected to it.

like image 161
Damian Leszczyński - Vash Avatar answered Oct 27 '22 11:10

Damian Leszczyński - Vash