简体   繁体   English

Android项目Build,Gradle错误

[英]Android project Build, Gradle error

I am trying to build a project, which is extracted from Github. 我正在尝试构建一个项目,该项目是从Github中提取的。 However building it results in CreateProcess error=2 The system cannot find the file specified . 但是,构建它会导致CreateProcess error=2 The system cannot find the file specified This is the project I am building. 这是我正在建立的项目。

And here is the build.gradle file code: 这是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.+"

}

Since this is the first time I am building another project from Git, I am clueless where I am doing wrong. 因为这是我第一次从Git构建另一个项目,所以我不知道哪里做错了。 The past questions too doesnt seems helpful. 过去的问题似乎也没有帮助。 Any help will be appreciated. 任何帮助将不胜感激。

You need to add "Git" bin folder location to Environment path. 您需要将“ Git” bin文件夹位置添加到环境路径。 I too had the same issue. 我也有同样的问题。 I've added the Git to Windows Environment variables and tried the command 'git rev-parse --short HEAD' in command prompt and it was working. 我已经将Git添加到Windows环境变量中,并在命令提示符下尝试了命令'git rev-parse --short HEAD',并且该命令正在运行。 Then after restarting the studio, the error was gone. 然后,重新启动Studio后,错误消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM