[英]“Error:(22, 0) CreateProcess error=2, The system cannot find the file specified” how to use git command in build.gradle
我用gradle導入了其他人的android項目,但是在同步gradle項目時出現了問題,它將顯示
CreateProcess錯誤= 2,系統找不到指定的文件
比我讀到日志詳細信息,它說
引起原因:java.io.IOException:無法運行程序“ git”
這是我的build.gradle文件HEAD代碼:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
maven { url 'http://dl.bintray.com/populov/maven' }
mavenCentral()
}
android {
/**
* Gets the git sha prefix 7
*/
def getCommitSha = { ->
def sha = "git rev-parse --verify HEAD".execute()
def formatRule = "cut -b 1-7".execute()
def shaText = (sha | formatRule).text.trim()
return shaText
}
請告訴我,如何在build.gradle文件中使用git命令?還是我丟失了一些.exe?
我已經安裝了git.exe,謝謝
終於我解決了這個問題。 我的操作系統引起的問題是Windows,但使用Linux命令。 因此,當我安裝cygwin並添加路徑變量然后重新啟動計算機時,此問題已解決。
您可以打開Android Studio並轉到:設置->版本控制-> Git在“ Git可執行文件的路徑”旁邊的文本框中,您將看到“ git.exe”,然后只給它一個完整的路徑,如下所示:
C:\\ Users \\您的用戶名\\ AppData \\ Local \\ GitHub \\ PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8 \\ bin \\ git.exe
它將工作並享受編碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.