google-ar / arcore-unity-sdk

ARCore SDK for Unity
https://developers.google.com/ar
Other
1.4k stars 402 forks source link

libarcore_camera_utility.so does not have arm64bit version #646

Open falldeaf opened 5 years ago

falldeaf commented 5 years ago

SPECIFIC ISSUE ENCOUNTERED

libarcore_camera_utility.so does not have 64bit version so my program gets an error when trying to reference this file:

DllNotFoundException: Unable to load DLL 'arcore_camera_utility': The specified module could not be found. at UnityARInterface.ARCoreInterface.TextureReader_create (Int32 format, Int32 width, Int32 height, Boolean keepAspectRatio) [0x00000] in at UnityARInterface.ARCoreInterface+c__Iterator0.MoveNext () [0x00000] in at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

  1. Include ARCore unity package in project
  2. build for il2cpp arm64

WORKAROUNDS (IF ANY)

Build the 64bit library yourself with NDK-BUILD

To compile arcore_camera_utility for the arm 64bit target-

1.) Create a new directory called 'arcorelibrary', then a subdirectory called 'jni'

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

3.) get the three .cc files and the three .h files and place them in the jni directory

4.) Create a file called 'Android.mk' and place it in the jni directory, with the following contents:

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.) Create a file called 'Application.mk' and place it in the jni directory, with the following contents:

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

6.) Download Android NDK and unzip somewhere (The version you need depends on which Unity version you're using) https://developer.android.com/ndk/downloads/older_releases.html

7.) Open a terminal or powershell, go to the root directory (arcorelibrary) of your project

8.) Create a path to where ever you unzipped Android NDK (Powershell example):

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

9.) Run:

ndk-build.cmd