Android Studio NDK构建问题错误:任务执行失败':app:compileReleaseNdk'

时间:2016-05-12 04:56:09

标签: android-studio build.gradle

我使用最新的android studio build 1.5,因为我想导入一个需要NDK的eclipse项目。我的项目正在运作。但是当我构建APK时,它会犯错:

apply plugin: 'com.android.application'
import org.apache.tools.ant.taskdefs.condition.Os

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "vaeapp.gamecard.vn"
        minSdkVersion 14
        targetSdkVersion 19
        multiDexEnabled = true
        versionCode 4
        versionName "1.3.4"

        ndk {
            moduleName "gc"
        }
    }
    // call regular ndk-build(.cmd) script from app directory
    task ndkBuild(type: Exec) {
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
        } else {
            commandLine 'ndk-build', '-C', file('src/main').absolutePath
        }
    }

    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    compile 'com.facebook.android:facebook-android-sdk:4.2.0'
    // compile 'com.android.support:appcompat-v7:20.0.0'
//    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.android.gms:play-services:4.0.30'
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/error-reporter.jar')
    //compile files('libs/httpclient-4.0.1.jar')
    compile files('libs/mail.jar')
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    // compile 'com.parse:parse-android:1.10.1'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.parse:parse-android:1.+'
}

我的build.gradle:

 if ($_FILES['filecv']['name'] != "") {
        $sqldata['att_ment'] = uploadCVFile($_FILES['filecv']);
    } else {
        $sqldata['att_ment'] = '';
    }

请帮我修复错误。谢谢你!

1 个答案:

答案 0 :(得分:2)

而不是仅使用此

 // call regular ndk-build(.cmd) script from app directory
    task ndkBuild(type: Exec) {
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
        } else {
            commandLine 'ndk-build', '-C', file('src/main').absolutePath
        }
    } 

使用此

 // call regular ndk-build(.cmd) script from app directory
    task ndkBuild(type: Exec) {
        if (Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
        } else {
            commandLine 'ndk-build', '-C', file('src/main').absolutePath
        }
    }

   tasks.withType(JavaCompile) {
        compileTask -> compileTask.dependsOn ndkBuild
    }