Android Studio + Experimental Gradle Plugin + NDK + OpenCV: display error in opencv include statement

I am integrating the opencv library with my project. I successfully configured NDK with the experimental gradle plugin. But an error with Opencv. Here is the error displayed in my cpp file.

enter image description here

My build.gradle:

apply plugin: 'com.android.model.application'
model {
     android {
       compileSdkVersion = 23
       buildToolsVersion = "23.0.0"

       defaultConfig.with {
        applicationId = "com.legalplex.dharani.android"
        minSdkVersion.apiLevel = 14
        targetSdkVersion.apiLevel = 23

        buildConfigFields.with {
            create() {
                type = "int"
                name = "VALUE"
                value = "1"
            }
        }
    }
  }
  android.ndk {
    moduleName = "document_scanner"
     cppFlags += "-fno-rtti"
     cppFlags += "-fno-exceptions"
     ldLibs    = ["android", "log"]

    stl ="gnustl_shared"
   }
   android.buildTypes {
        release {
            minifyEnabled = false
            proguardFiles += file('proguard-rules.pro')
        }
   }
   android.productFlavors {
    // for detailed abiFilter descriptions, refer to "Supported ABIs" @
    // https://developer.android.com/ndk/guides/abis.html#sa
    create("arm") {
        ndk.abiFilters += "armeabi"
    }
    create("arm7") {
        ndk.abiFilters += "armeabi-v7a"
    }
    create("arm8") {
        ndk.abiFilters += "arm64-v8a"
    }
    create("x86") {
        ndk.abiFilters += "x86"
    }
    create("x86-64") {
        ndk.abiFilters += "x86_64"
    }
    create("mips") {
        ndk.abiFilters += "mips"
    }
    create("mips-64") {
        ndk.abiFilters += "mips64"
    }
    // To include all cpu architectures, leaves abiFilters empty
    create("all")
    }
    }
    dependencies {
        compile 'com.android.support:support-v4:19.1.0'
       compile project(':openCVLibrary')
    }

Why it shows an error in opencv, includes even after adding a module dependency in my gradle file. Please help me. How to configure build.gradle file to activate our Android.mk. Here is my Android.mk file:

  LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)
  include OpenCV-2.4.10-android-sdk\sdk\native\jni\OpenCV.mk
  OPENCV_INSTALL_MODULES := on
  LOCAL_MODULE := document_scanner
  LOCAL_SRC_FILES := jni_part.cpp
  LOCAL_C_INCLUDES := OpenCV-2.4.10-android-sdk\sdk\native\jni\include
  OPENCV_LIB_TYPE:=STATIC
  LOCAL_LDLIBS += -llog
  include $(BUILD_SHARED_LIBRARY)
+4
source share
1 answer

a) ndk-build b) ndk. Mac, Windows ndk-build.cmd:

task buildNative(type: Exec, description: 'Compile JNI source via NDK') {
    def ndkDir = android.ndkDirectory
    commandLine "$ndkDir/ndk-build"
}
buildNative.onlyIf {
    def ndkDir = android.ndkDirectory
    file("$ndkDir/ndk-build").exists()
}

task cleanNative(type: Exec, description: 'Clean JNI object files') {
    def ndkDir = android.ndkDirectory
    commandLine "$ndkDir/ndk-build", 'clean'
}
cleanNative.onlyIf {
    def ndkDir = android.ndkDirectory
    file("$ndkDir/ndk-build").exists()
}

clean.dependsOn 'cleanNative'

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn buildNative
}

defaultConfig.ndk {
    moduleName "pexeso-android-mobile"
}

tasks.all {
    task -> if (task.name.contains('compileDebugNdk') || task.name.contains('compileReleaseNdk')) task.enabled = false
}

UPDATE , . LOCAL_SRC_FILES ndk {} DSL.

-1

All Articles