Roy Huang
Roy Huang

Reputation: 41

"Error:(22, 0) CreateProcess error=2, The system cannot find the file specified" how to use git command in build.gradle

I import other people android project with gradle, but I got a problem when I sync gradle project , it will show

CreateProcess error=2, The system cannot find the file specified

than I read log deteil message , it says

Caused by: java.io.IOException: Cannot run program "git"

here is my build.gradle file HEAD code:

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
  }

please tell me ,how to use git command in build.gradle file?or I lost some .exe?

I already install git.exe ,thanks

Upvotes: 1

Views: 3521

Answers (2)

Maksudul Hasan Raju
Maksudul Hasan Raju

Reputation: 875

You can open the Android studio and go to : Settings -> Version Control -> Git In text box next to "Path to Git Executable" you will see "git.exe", then you just give it a full path like this:

C:\Users\Your_Username\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\bin\git.exe

It will work and enjoy coding.

Upvotes: 0

Roy Huang
Roy Huang

Reputation: 41

Finally I has been solved this problem. The problem caused by my os is windows but use Linux command. so when I installed cygwin and add path variable then restart computer,this problem was solved.

Upvotes: 3

Related Questions