Ask Your Question

Android Studio how integrate NDK with Opencv

asked 2019-06-05 08:38:21 -0500

Jayapriya gravatar image

updated 2019-12-10 01:08:21 -0500

Akhil Patel gravatar image

How to Intregrate an OpenCv with NDK?

i have make changes cmlists.txt I Got Error Execution failed for task ':app:externalNativeBuildDebug'.

Build command failed. Error while executing process C:\Users\Lenovo\AppData\Local\Android\Sdk\cmake\\bin\cmake.exe with arguments {--build C:\Users\Lenovo\Pictures\jp\crop\CricleDection\app.externalNativeBuild\cmake\debug\armeabi-v7a --target native-lib} [1/2] Building CXX object CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o FAILED: CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o C:\Users\Lenovo\AppData\Local\Android\sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=armv7-none-linux-androideabi19 --gcc-toolchain=C:/Users/Lenovo/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/Users/Lenovo/AppData/Local/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Dnative_lib_EXPORTS -I/sdk/native/jni/include -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mfpu=vfpv3-d16 -fno-addrsig -march=armv7-a -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -stdlib=libc++ -std=c++11 -frtti -fexceptions -std=gnu++11 -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o -MF CMakeFiles\native-lib.dir\src\main\cpp\native-lib.cpp.o.d -o CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o -c ../../../../src/main/cpp/native-lib.cpp ../../../../src/main/cpp/native-lib.cpp:3:10: fatal error: 'opencv2/core/core.hpp' file not found #include <opencv2 core="" core.hpp="">

My Cmlists.txt cmake_minimum_required(VERSION 3.4.1)

set(pathToOpenCV /C:/Users/Lenovo/Pictures/jp/opcv/3.4.3/OpenCV-android-sdk/sdk/native) include_directories(${pathToOpenCV}/jni/include) add_library( # Sets the name of the library. native-lib src/main/cpp/native-lib.cpp )

add_library( lib_opencv SHARED IMPORTED ) set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION /C:/Users/Lenovo/Pictures/jp/crop/Native/app/src/main/jniLibs/${ANDROID_ABI}/

find_library(log-lib log )

target_link_libraries( native-lib ${log-lib} lib_opencv) #EDIT

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-06-05 23:35:54 -0500

Akhil Patel gravatar image

updated 2019-11-23 02:07:12 -0500

In your CMakeLists.txt add this and your build.gradle file must add following lines.

   externalNativeBuild {
        cmake {
            cppFlags "-frtti -fexceptions"
            abiFilters 'armeabi-v7a', 'arm64-v8a'

            jni.srcDirs = []
            jniLibs.srcDir 'src/main/libs'

    externalNativeBuild {
    cmake {
        path "src/main/cpp/CMakeLists.txt"
        version "3.10.2"
edit flag offensive delete link more



Thank for response. I saw Your Question Document Detection working with C++ code, But trouble in java conversion. I am developing Document Scanner app . I am Stuck Could Help Me.

Jayapriya gravatar imageJayapriya ( 2019-06-08 07:40:56 -0500 )edit
1 I am this algorithm in C++ ,I am not getting this expected output . Please Help . I am Stucking For month

Jayapriya gravatar imageJayapriya ( 2019-06-08 07:49:05 -0500 )edit

Question Tools

1 follower


Asked: 2019-06-05 08:38:21 -0500

Seen: 1,247 times

Last updated: Nov 23 '19