对于我尝试运行的任何项目,ndk-build 都以错误结束。我在 Windows 8.1 上使用带有 ndk-bundle 的 androidSDK 1.3 第二个空 .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
}
}