I am getting a weird error on Android Studio 1.0.2 on Mac OSX Yosemite. The project doesn't build and I get
我在Mac OSX Yosemite上的Android Studio 1.0.2上有一个奇怪的错误。这个项目没有建立,我得到了。
Error:(8, 0) Cause: error=2, No such file or directory
错误:(8,0)原因:错误=2,没有这样的文件或目录。
Where line number 8 is
第8行在哪里?
def gitSha = 'git rev-parse --short HEAD'.execute().text.trim()
def gitSha = 'git rev-parse -short HEAD'.execute().text.trim()
I am able to build the project through command line. It seems that Android studio isn't able to run git commands.
我可以通过命令行来构建项目。似乎Android studio无法运行git命令。
EDIT: It happened after I uninstalled older git(1.9) and installed updated one (2.0.1)
编辑:在我卸载了旧的git(1.9)并安装了更新的(2.0.1)之后。
2 个解决方案
#1
3
Use full path of git instead.
使用git的完整路径。
e.g. "/usr/local/bin/git rev-parse --short HEAD"
如。“/ usr /地方/ bin / git rev-parse——短头”
you can find you git path by running the command "which git" in the terminal.
您可以通过运行终端中的“git”命令找到git路径。
#2
0
EDIT: I work with a multiple developer team. We use Linux, Windows, and OSX. "return 'git rev-parse --short HEAD'.execute().text.trim()" works for Windows and Linux, but not for Mac OS. We tried many ways to not have to use an if statement, but MacOS seems to need an absolute path. So our fix was to import org.apache.tools.ant.taskdefs.condition.Os at the top of the build.gradle file and add the if statement. Os.isFamily(Os.FAMILY_MAC) returns a boolean.
编辑:我和一个多开发团队合作。我们使用Linux、Windows和OSX。"返回'git rev-parse -short HEAD'.execute().text.trim()"适用于Windows和Linux,但不适用于Mac OS。我们尝试了很多方法来不必使用if语句,但是MacOS似乎需要一条绝对路径。因此,我们的解决方案是导入org.apache.tools.ant.taskdefs.condition。在构建的顶部操作系统。gradle文件并添加if语句。Os.isFamily(Os.FAMILY_MAC)返回一个布尔值。
I found this to work for me:
我发现这是为我工作的:
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()
}
}
#1
3
Use full path of git instead.
使用git的完整路径。
e.g. "/usr/local/bin/git rev-parse --short HEAD"
如。“/ usr /地方/ bin / git rev-parse——短头”
you can find you git path by running the command "which git" in the terminal.
您可以通过运行终端中的“git”命令找到git路径。
#2
0
EDIT: I work with a multiple developer team. We use Linux, Windows, and OSX. "return 'git rev-parse --short HEAD'.execute().text.trim()" works for Windows and Linux, but not for Mac OS. We tried many ways to not have to use an if statement, but MacOS seems to need an absolute path. So our fix was to import org.apache.tools.ant.taskdefs.condition.Os at the top of the build.gradle file and add the if statement. Os.isFamily(Os.FAMILY_MAC) returns a boolean.
编辑:我和一个多开发团队合作。我们使用Linux、Windows和OSX。"返回'git rev-parse -short HEAD'.execute().text.trim()"适用于Windows和Linux,但不适用于Mac OS。我们尝试了很多方法来不必使用if语句,但是MacOS似乎需要一条绝对路径。因此,我们的解决方案是导入org.apache.tools.ant.taskdefs.condition。在构建的顶部操作系统。gradle文件并添加if语句。Os.isFamily(Os.FAMILY_MAC)返回一个布尔值。
I found this to work for me:
我发现这是为我工作的:
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()
}
}