- delete the jniLibs folder and each such file, you do not need them.
- Define the NDK path in the
local.properties file:
sdk.dir = D: \ Android \ SDK
ndk.dir = D: \ Android \ NDK - create a folder (I named it jni) and put Android.mk and Application.mk in it (and an empty dummy.c file to prevent errors in the future)
- as Roy said, Android Studio creates its own Android.mk, we have our own Android.mk file, and Android Studio must use it.
jni.srcDirs = [] prevents this generation! - Extract openCV sources somewhere, I will put them here:
D:\Android\Libs\OpenCV - here are my files, modify and use them
build.gradle:
apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "your.package" minSdkVersion 11 targetSdkVersion 22 versionCode 1 versionName "1.0" } sourceSets { main { jni.srcDirs = [] } } task ndkBuild(type: Exec) { commandLine file('D:\\Android\\NDK\\ndk-build.cmd').absoluteFile, 'NDK_PROJECT_PATH='+file('src\\main\\jni').absolutePath, 'APP_BUILD_SCRIPT='+file('src\\main\\jni\\Android.mk').absolutePath, 'NDK_APPLICATION_MK='+file('src\\main\\jni\\Application.mk').absolutePath, 'NDK_LIBS_OUT='+file('src\\main\\jniLibs').absolutePath } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' compile project(':openCVLibrary300rc1') }
Application.mk:
APP_STL := gnustl_static APP_CPPFLAGS := -frtti -fexceptions APP_ABI := armeabi-v7a x86 APP_PLATFORM := android-8
Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)
source share