如何在AndroidStudio sdk1.3下配置项目,在Win8.1上使用ndk正确构建?

时间:2015-08-05 14:50:06

标签: ndk-build

ndk-build以我尝试运行的任何项目的错误结束。 我在Windows 8.1上使用androidSDK 1.3和ndk-bundle 第二个空的.c文件添加到jni文件夹; local.properties显示sdk和ndk路径更正:

ndk.dir=C\:\\Users\\JL\\AppData\\Local\\Android\\sdk\\ndk-bundle
sdk.dir=C\:\\Users\\JL\\AppData\\Local\\Android\\sdk

error message:
* What went wrong:
Execution failed for task ':app:ndkBuild'.
> A

启动进程'命令'ndk-build.cmd''

时出现问题
import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc3"

    defaultConfig{
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }

    sourceSets.main {
        jniLibs.srcDir 'src/main/libs'
        jni.srcDirs = [] //disable automatic ndk-build call
    }

    project.ext.versionCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9] //versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*

        android.applicationVariants.all { variant ->
            // assign different version code for each output
            variant.outputs.each { output ->
                output.versionCodeOverride =
                    project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + defaultConfig.versionCode
            }
        }

    // 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/jni').absolutePath
        } else {
            commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath
        }
    }

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

0 个答案:

没有答案