【发布时间】:2017-03-23 18:25:19
【问题描述】:
我在我的项目中使用 android Ndk,每当我想构建我的项目时,它都会显示此错误
错误:任务 ':app:ndkBuild' 执行失败。处理'命令 'E:/Android/sdk/ndk-bundle/ndk-build.cmd'' 以非零退出完成 值 2
我已经创建了 android.mk 和 application.mk
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
C:\OpenCV-2.4.9-android-sdk
#opencv
OPENCVROOT:= C:\OpenCV-2.4.9-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LLB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES :=com_example_abr_ndkopencvtest2_OpencvNativeClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyOpencvLibs
include $(BUILD_SHARED_LIBRARY)
build.gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.abr.ndkopencvtest2"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets.main{
jni.srcDirs = []
}
task ndkBuild(type: Exec,description: 'Compile JNI source via NDK'){
commandLine "E:/Android/sdk/ndk-bundle/ndk-build.cmd",
'NDK_PROJECT_PATH = build/intermediates/ndk',
'NDK_LIBS_OUT=src/main/jniLibs',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile){
compileTask -> compileTask.dependsOn ndkBuild
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary249')
}
【问题讨论】:
标签: opencv android-ndk