I know there is several questions with the same title but after working my way through every single one I could find for hours, I decided to post a new question.
my Android.mk looks like
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := com_lunaticcoding_colosseum_OpenCv.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := OpenCvFace
include $(BUILD_SHARED_LIBRARY)
my Application.mk
APP_OPTIM := release
APP_PLATFORM := android-21
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI := armeabi-v7a
my .h file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#include "opencv2/opencv.hpp"
/* Header for class com_lunaticcoding_colosseum_OpenCv */
#ifndef _Included_com_lunaticcoding_colosseum_OpenCv
#define _Included_com_lunaticcoding_colosseum_OpenCv
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_lunaticcoding_colosseum_OpenCv
* Method: faceDetection
* Signature: (J)V
*/
void detect(Mat& frame);
JNIEXPORT void JNICALL Java_com_lunaticcoding_colosseum_OpenCv_faceDetection
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
#endif
my .cpp file
#include <jni.h>
#include "com_lunaticcoding_colosseum_OpenCv.h"
JNIEXPORT void JNICALL Java_com_lunaticcoding_colosseum_OpenCv_faceDetection
(JNIEnv *, jclass, jlong addrRgba){
//Mat& frame = *(Mat *) addrRgba;
//detect(frame);
}
void detect(Mat& frame) {
}
I added android.useDepricatedNdk=true to the properties file and my "error message" looks like:
EDIT (removed the error message because obsolete and makes question more difficult to read) (Reg. Adding OpenCV to Native C code through CMake on Android Studio) I feel like I am really close :O but no clue what I am missing now
#include <jni.h>
#include <string>
#include <opencv>
extern "C" JNIEXPORT jstring
JNICALL
Java_com_lunaticcoding_opencvtest_MainActivity_getFace(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from test";
return env->NewStringUTF(hello.c_str());
}
following error
Build command failed. Error while executing process /Users/lunaticcoding/Library/Android/sdk/cmake/3.6.4111459/bin/cmake with arguments {--build /Users/lunaticcoding/AndroidStudioProjects/OpenCvTest2/app/.externalNativeBuild/cmake/debug/x86_64 --target OpenCvFace} [1/2] Building CXX object CMakeFiles/OpenCvFace.dir/src/main/cpp/OpenCvFace.cpp.o FAILED: /Users/lunaticcoding/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=x86_64-none-linux-android --gcc-toolchain=/Users/lunaticcoding/Library/Android/sdk/ndk-bundle/toolchains/x86_64-4.9/prebuilt/darwin-x86_64 --sysroot=/Users/lunaticcoding/Library/Android/sdk/ndk-bundle/sysroot -DOpenCvFace_EXPORTS -isystem /Users/lunaticcoding/Documents/OpenCV-android-sdk/sdk/native/jni/include -isystem /Users/lunaticcoding/Documents/OpenCV-android-sdk/sdk/native/jni/include/opencv -isystem /Users/lunaticcoding/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem /Users/lunaticcoding/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include -isystem /Users/lunaticcoding/Library/Android/sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -isystem /Users/lunaticcoding/Library/Android/sdk/ndk-bundle/sysroot/usr/include/x86_64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -frtti -fexceptions -O0 -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/OpenCvFace.dir/src/main/cpp/OpenCvFace.cpp.o -MF CMakeFiles/OpenCvFace.dir/src/main/cpp/OpenCvFace.cpp.o.d -o CMakeFiles/OpenCvFace.dir/src/main/cpp/OpenCvFace.cpp.o -c /Users/lunaticcoding/AndroidStudioProjects/OpenCvTest2/app/src/main/cpp/OpenCvFace.cpp /Users/lunaticcoding/AndroidStudioProjects/OpenCvTest2/app/src/main/cpp/OpenCvFace.cpp:3:10: fatal error: 'opencv' file not found include ^~~~~~~~ 1 error generated. ninja: build stopped: subcommand failed.