android - ndk 中的未知类型名称“ACameraDevice”
问题描述
我想用 NDK 在 android 中开发 opencv 程序,因为我试图在 android studio 中构建这个示例项目,但是在制作项目时会出现这些错误:
Build command failed.
Error while executing process E:\SoftWare\Android\android-ndk-r19c\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Android.mk NDK_APPLICATION_MK=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Application.mk APP_ABI=x86_64 NDK_ALL_ABIS=x86_64 NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\build\intermediates\ndkBuild\debug\lib APP_CPPFLAGS+=-std=c++14 C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/libopencv_ndk.so}
[x86_64] Compile++ : opencv_ndk <= native-lib.cpp
In file included from C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/native-lib.cpp:4:
In file included from C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/CV_Main.h:15:
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:15:55: error: unknown type name 'ACameraDevice'
static void CameraDeviceOnDisconnected(void* context, ACameraDevice* device) {
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:18:48: error: unknown type name 'ACameraDevice'
static void CameraDeviceOnError(void* context, ACameraDevice* device,
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:25:35: error: unknown type name 'ACameraCaptureSession'
ACameraCaptureSession* session) {
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:29:36: error: unknown type name 'ACameraCaptureSession'
ACameraCaptureSession* session) {
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:52:3: error: unknown type name 'ACameraDevice'
ACameraDevice* m_camera_device;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:53:3: error: unknown type name 'ACaptureRequest'
ACaptureRequest* m_capture_request;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:54:3: error: unknown type name 'ACameraOutputTarget'
ACameraOutputTarget* m_camera_output_target;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:55:3: error: unknown type name 'ACaptureSessionOutput'
ACaptureSessionOutput* m_session_output;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:56:3: error: unknown type name 'ACaptureSessionOutputContainer'
ACaptureSessionOutputContainer* m_capture_session_output_container;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:57:3: error: unknown type name 'ACameraCaptureSession'
ACameraCaptureSession* m_capture_session;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:59:3: error: unknown type name 'ACameraDevice_StateCallbacks'
ACameraDevice_StateCallbacks m_device_state_callbacks;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:60:3: error: unknown type name 'ACameraCaptureSession_stateCallbacks'
ACameraCaptureSession_stateCallbacks m_capture_session_state_callbacks;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:62:3: error: unknown type name 'ACameraManager'
ACameraManager* m_camera_manager;
^
C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/src/main/cpp/Native_Camera.h:64:3: error: unknown type name 'ACameraIdList'
ACameraIdList* m_camera_id_list = NULL;
^
14 errors generated.
make: *** [C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj/local/x86_64/objs-debug/opencv_ndk/native-lib.o] Error 1
环境细节:
NDK 版本:r19c
主机操作系统:Windows
IDE:Android Studio 3.3.2
SDK平台工具:28.0.2
SDK工具:25.2.5
解决方案
要使用本机 camera2 API,请将您的APP_PLATFORM设置为android-24或更高版本。在 Android Studio 中,这对应于脚本中的minSdkVersion 。build.gradle
推荐阅读
- unity3d - 根运动后更新变换位置
- php - 没有 $_POST 变量
- security - 如何查看我的 android ssh 客户端连接的算法?
- python - “TypeError: 'type' 类型的对象没有 len()” - Python 上的线性搜索
- homebrew - Homebrew 错误:无效选项 --with-clang
- c - 使用 curl 将数据从 URL 复制到文件中并同时访问该文件
- javascript - React 组件未列出 hidden.bs.modal(模态隐藏)事件 - Bootsrap 4
- python - Python Django列出属于一个类别的所有帖子
- javascript - 如何将 html 部分包含到 PHP 中的所有页面中
- jenkins-plugins - 从 csv 文件中获取数据并在 jenkins 中绘制图形