Android项目构建,Gradle错误

Android项目构建,Gradle错误,android,git,gradle,Android,Git,Gradle,我正在尝试构建一个项目,它是从Github中提取的。但是,构建它会导致createprocesserror=2系统无法找到指定的文件 下面是build.gradle文件代码: apply plugin: 'com.android.application' def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim() def buildTime = new Date().format(

我正在尝试构建一个项目,它是从Github中提取的。但是,构建它会导致
createprocesserror=2
系统无法找到指定的文件

下面是
build.gradle
文件代码:

    apply plugin: 'com.android.application'

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm'Z'", TimeZone.getTimeZone("UTC"))

def isTravis = "true".equals(System.getenv("TRAVIS"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))


android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    dexOptions {
        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
        preDexLibraries = preDexEnabled && !isTravis
    }

    defaultConfig {
        applicationId "org.fossasia.openevent"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "0.1"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
        buildConfigField "String", "BUILD_TIME", "\"${buildTime}\""
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        fdroid {
        }
        googleplay {
        }
    }
    packagingOptions {
        exclude 'LICENSE.txt'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup:otto:1.3.8'

    googleplayCompile 'com.google.android.gms:play-services-maps:7.5.0'

    fdroidCompile 'org.osmdroid:osmdroid-android:4.3'
    fdroidCompile 'org.apache.directory.studio:org.slf4j.api:1.7.2'
    fdroidCompile 'org.slf4j:slf4j-simple:1.7.12'
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    androidTestCompile 'com.android.support.test:rules:0.3'
    androidTestCompile "org.mockito:mockito-core:1.+"

}

因为这是我第一次从Git构建另一个项目,所以我不知道哪里做错了。过去的问题似乎也没有帮助。任何帮助都将不胜感激。

您需要将“Git”bin文件夹位置添加到环境路径。我也有同样的问题。我已经将Git添加到Windows环境变量中,并在命令提示符中尝试了命令“Git rev parse--short HEAD”,它正常工作。重新启动studio后,错误消失。

您需要将“Git”bin文件夹位置添加到环境路径。我也有同样的问题。我已经将Git添加到Windows环境变量中,并在命令提示符中尝试了命令“Git rev parse--short HEAD”,它正常工作。重新启动studio后,错误消失。

这应该是因为这一行proguardFiles getDefaultProguardFile('proguard-android.txt')。该文件应该丢失或不在预期路径中。这应该是因为这一行proguardFiles getDefaultProguardFile('proguard-android.txt')。文件应丢失或不在预期路径中。如何添加?请列出stepHow要添加的步骤?请逐项列出