如何在 NDK-BUILD 中构建 arcore camera_utility 共享库?

How do I build the arcore camera_utility shared library in NDK-BUILD?

我正在尝试在 NDK_BUILD 中构建 'arcore camera utility' 库,此处:https://github.com/google-ar/arcore-unity-sdk/tree/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src

使用本指南:https://yeephycho.github.io/2016/10/20/How-to-Use-NDK-to-Build-A-Shared-Android_Native-Library/ 我至少能够将其编译到 libarcore_camera_utility.so 文件中。不仅如此,我的应用程序实际上在 phone 上识别了它,我没有收到 DLL 丢失错误,而是收到错误:"EntryPointNotFoundException: Unable to find an entry point named 'TextureReader_create' in 'arcore_camera_utility'.",这意味着它现在至少找到了文件。

.so 的文件大小只有 6k,所以我似乎没有正确编译它,因为软件包附带的已经工作的 32 位版本是 100k,基于这个问题,我似乎要离开了出什么事了?:Entry point not found, Android .so file

我的 Android.mk 文件是:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility_shared
LOCAL_C_INCLUDES += \
LOCAL_SRC_FILES := camera_utility.cc gl_utility.cc texture_reader.cc
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility
LOCAL_WHOLE_STATIC_LIBRARIES := arcore_camera_utility_shared
include $(BUILD_SHARED_LIBRARY)

我的 Application.mk 文件包含:

APP_ABI := arm64-v8a
APP_PLATFORM := android-24
APP_STL := c++_static
APP_BUILD_SCRIPT := ./jni/Android.mk

我是否以省略代码的方式构建它?

为arm 64位目标编译arcore_camera_utility-

1.) 创建一个名为 'arcorelibrary' 的新目录,然后创建一个名为 'jni'

的子目录

2.) 下载此 zip:https://github.com/google-ar/arcore-unity-sdk/blob/master/Assets/GoogleARCore/Examples/ComputerVision/Plugins/src/arcore_camera_utility.zip

3.) 获取三个.cc文件和三个.h文件放在jni目录下

4.) 创建一个名为'Android.mk' 的文件并将其放在jni 目录中,内容如下:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= arcore_camera_utility_static
LOCAL_SRC_FILES:= camera_utility.cc gl_utility.cc texture_reader.cc
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS    := -llog -landroid -lEGL -lGLESv2 -lGLESv3
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := arcore_camera_utility
LOCAL_WHOLE_STATIC_LIBRARIES := arcore_camera_utility_static
include $(BUILD_SHARED_LIBRARY)

5.) 创建一个名为'Application.mk' 的文件并将其放在jni 目录中,内容如下:

APP_ABI := arm64-v8a
APP_PLATFORM := android-24
APP_STL := c++_static
APP_BUILD_SCRIPT := ./jni/Android.mk

6.) 下载 Android NDK 并解压到某处(您需要的版本取决于您使用的 Unity 版本)https://developer.android.com/ndk/downloads/older_releases.html

7.) 打开终端或 powershell,转到项目的根目录 (arcorelibrary)

8.) 创建一条路径到你解压缩的地方 Android NDK(Powershell 示例):

$env:Path += ";C:\[where-ever-you-unzipped]\android-ndk-r13b-windows-x86_64\android-ndk-r13b"

9.) 运行:

ndk-build.cmd