Android studio gradle, error: Reason: error = 2, There is no such file or directory

I get a strange error in Android Studio 1.0.2 on Mac OSX Yosemite. The project is not under construction and I get

Error:(8, 0) Cause: error=2, No such file or directory

If line number 8

def gitSha = 'git rev-parse --short HEAD'.execute().text.trim()

I can build the project through the command line. It seems that Android studio cannot run git commands.

EDIT: This happened after I removed the old git (1.9) and installed the updated (2.0.1)

+4
source share
2 answers

Use the full git path instead.

eg. "/ usr / local / bin / git rev-parse --short HEAD"

you can find the git path by running the "which git" command in the terminal.

+3
source

EDIT: . Linux, Windows OSX. "return" git rev-parse --short HEAD..execute(). text.trim() " Windows Linux, Mac OS. if, MacOS, , . , org.apache.tools.ant.taskdefs.condition.Os build.gradle if. Os.isFamily(Os.FAMILY_MAC) .

, :

import org.apache.tools.ant.taskdefs.condition.Os

....

def getVersion(){
    if (Os.isFamily(Os.FAMILY_MAC)) {
        return  '/usr/local/bin/git rev-parse --short HEAD'
                .execute().text.trim()
    } else {
        return  'git rev-parse --short HEAD'.execute().text.trim()
    }
}
0

Source: https://habr.com/ru/post/1568288/


All Articles