'How to use onnxruntime in a native android library

I need to use the onnxruntime library in an Android project, but I can't understand how to configure CMake to be able to use C++ headers and *.so from AAR. I created a new Android Native Library module and put onnxruntime-mobile-1.11.0.aar into libs but wen I do #include "onnxruntime_cxx_api.h" in my C++ code I encounter with an error:

In file included from /Users/ash/AndroidStudioProjects/cv-demo/android/src/nativelib/src/main/cpp/OrtInferenceSession.cpp:8: /Users/ash/AndroidStudioProjects/cv-demo/android/src/nativelib/src/main/cpp/OrtInferenceSession.hpp:20:10: fatal error: 'onnxruntime_cxx_api.h' file not found

I see that the files I need are packed in AAR:

enter image description here

How to specify paths to headers and *.so inside onnxruntime-mobile-1.11.0.aar in my CMakeLists.txt to use them in my C++ code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source