android - Android项目Build,Gradle错误

标签 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构建另一个项目,所以我不知道哪里做错了。过去的问题似乎也没有帮助。任何帮助将不胜感激。

最佳答案

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

关于android - Android项目Build,Gradle错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33821982/

相关文章:

android - 如何将 ARC Welder 用作 Android 模拟器

git fatal error : Unsupported SSL backend 'schannel'

git 克隆问题 : repo too large? (50m)

即使使用 --no-edit,Git Pull 也会打开 VIM

eclipse - 在命令行上使用gradle运行时,junit运行正常,但作为junit测试,无法在eclipse上运行

spring-boot - Spring Boot bootRun 持续构建

android - 无法启动 adb

android - 复合可绘制尺寸

java - 小部件 ID 和 Intent

android - 如何从 gradle 插件将文件夹添加到 android 项目源集中