Build OpenCV as part of Android AOSP

Hi,
I have an OpenCV executable that runs as a Deamon in Android AOSP.
I’ve built it by NDK using the following Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCVROOT := ${LOCAL_PATH}/…/…/OpenCV-android-sdk

OPENCV_CAMERA_MODULES := off

OPENCV_INSTALL_MODULES := on

OPENCV_LIB_TYPE := STATIC

include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk

LOCAL_SRC_FILES := readQr.cpp

LOCAL_LDLIBS := -lm -llog -ldl -lz

LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++17

LOCAL_LDFLAGS += -ljnigraphics

LOCAL_C_INCLUDES += ${OPENCVROOT}/sdk/native/jni/include \

${OPENCVROOT}/sdk/native/jni/include/opencv2

LOCAL_EXPORT_C_INCLUDES += ${OPENCVROOT}/sdk/native/jni/include \

${OPENCVROOT}/sdk/native/jni/include/opencv2

LOCAL_MODULE := opencv_readqr

include $(BUILD_EXECUTABLE)

APP_PLATFORM := android-21

Application.mk

APP_STL := c++_static

APP_CPPFLAGS += -fexceptions -frtti -std=c++11 -D__STDC_CONSTANT_MACROS

APP_ABI := all

APP_PLATFORM := android-21

And everything is work well when I push the executable to the /vendor/bin
But when I try to build it as part of the Android build(mm), I get the error:

You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing opencv_core (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing libprotobuf (STATIC_LIBRARIES android-arm)”
Available variants:
libprotobuf (DYLIB_LIBRARIES linux-x86_64)
libprotobuf (DYLIB_LIBRARIES linux-x86)
libprotobuf (DYLIB_LIBRARIES android-arm)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing ade (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing tbb (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing ittnotify (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing libjpeg-turbo (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing libwebp (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing libtiff (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing libopenjp2 (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing IlmImf (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing quirc (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
vendor/dolphin/ReadQr/…/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk: error: “opencv_readqr (EXECUTABLES android-arm) missing tegra_hal (STATIC_LIBRARIES android-arm)”
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
build/make/core/main.mk:1118: error: exiting from previous errors.
00:12:40 ckati failed with: exit status 1

Has anyone managed to build OpenCV as part of the Android build and can share their .mk file?

Thanks a lot!