Android项目Build,Gradle错误

时间:2015-11-20 08:21:21

标签: android git gradle

我正在尝试构建一个从Github中提取的项目。无论如何构建它都会产生CreateProcess error=2 The system cannot find the file specifiedThis is the project I am building.

这是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构建另一个项目,因此我无能为力。过去的问题似乎也没有用。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

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