我想使用OpenCV开发一个关于扫描图像或照片中的自动裁剪的Android应用程序。我找到了一个开源应用程序名称" android-opencv-scan-doc"在github。下载后,尝试在我的计算机上构建并运行此项目。应用程序无法启动并提供以下异常:
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
app build.gradle中的代码是:
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'
}
那我该怎么办?我不知道如何处理它们。提前谢谢。
答案 0 :(得分:1)
只需从项目路径中移除the white space
并尝试使用新的NDK(android-ndk-r10e-windows-x86_64
)它就可以正常使用
答案 1 :(得分:0)
首先,确保在“项目结构”对话框中设置了ndk路径。
如果这不是问题,请尝试调试ndkClean任务,因为这是构建失败的任务。您可以通过在“设置”对话框的编译器部分的“命令行选项”文本框中添加--stacktrace --debug
来创建更具信息性的gradle构建日志,或者尝试查看此任务中的行并查找有问题的行。< / p>
答案 2 :(得分:0)
我检查了许多任务,但没有任何工作。我已经为其他项目安装了NDK。但改变项目位置后解决我的问题。如果你面临问题将尝试这个。