如何修复错误:(158)Android NDK:正在中止. .停止. (ndk-build.cmd''以非零退出值2结束)
我想通过使用OpenCV开发有关在扫描的图像或照片中自动裁剪的android应用程序.我在 github 上找到了一个名为"android-opencv-scan-doc"的开源应用程序.一个>.下载后,请尝试在计算机上构建并运行此项目.该应用程序无法启动,并给出以下异常:
I want to develop an android application about Auto crop in a scanned image or photo by using OpenCV. I found an open source application name "android-opencv-scan-doc" on github. After I downloaded, try to build and run this project on my computer. The application can not start and gives the following exception:
Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
C:\Users\user\AppData\Local\Android\sdk\ndk-bundle\build\core\build-local.mk
Error:(158) *** Android NDK: Aborting. . Stop.
Error:Execution failed for task ':app:ndkClean'.
> Process 'command 'C:\Users\user\AppData\Local\Android\Sdk\ndk-bundle/ndk-build.cmd'' finished with non-zero exit value 2
Information:BUILD FAILED
应用程序build.gradle中的
代码是:
code in app build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.yangyao.android_opencv"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "OpenCV"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main.jni.srcDirs = []
sourceSets.main.jniLibs.srcDirs = ['src/main/libs','src/main/jniLibs']
task ndkBuild(type: Exec, description: 'Compile JNI source with NDK') {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
if (org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS)) {
commandLine "$ndkDir/ndk-build.cmd", '-C', file('src/main/jni').absolutePath
} else {
commandLine "$ndkDir/ndk-build", '-C', file('src/main/jni').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task ndkClean(type: Exec, description: 'Clean NDK Binaries') {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkDir = properties.getProperty('ndk.dir')
if (org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_WINDOWS)) {
commandLine "$ndkDir/ndk-build.cmd",'clean', '-C', file('src/main/jni').absolutePath
} else {
commandLine "$ndkDir/ndk-build",'clean', '-C', file('src/main/jni').absolutePath
}
}
clean.dependsOn 'ndkClean'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
那我该怎么办?我不知道该如何对付他们.预先感谢.
So what should i do? I do not know how to deal with them. Thanks in advance.
首先,确保在项目结构"对话框中具有ndk路径设置.
First, make sure you have the ndk path setup in Project Structure dialog.
如果这不是问题,请尝试调试ndkClean任务,因为这是构建失败的任务.您可以通过在设置"对话框的编译器"部分的命令行选项"文本框中添加--stacktrace --debug
来制作更详尽的gradle构建日志,或者尝试遍历此任务中的所有内容并找到有问题的代码.
If this is not the issue, try to debug ndkClean task, as this is the one failing the build. You can make a more informative gradle build log by adding --stacktrace --debug
in the Command-line Options text box on the compiler section in the Settings dialog, or try to go over the lines in this task and find the problematic one.