Duplicate libarcore_sdk_c.so error while bringing Android NDK plugin with ARCore into Unity

Viewed 50

I would like to expose some functionality written in C++ in Android NDK into Unity. The functionality relies on ARCore. But in order to compile the module in Android Studio, I need to bundle in libarcore_sdk_c.so. And Unity's ARFoundation also has a libarcore_sdk_c.so, so I'm getting an error due to the library being included twice.

To rule out my code, I reproduced the error with the ARCore sample project from the Android SDK:

  1. Take the hello_ar_application.cc sample project from the Android SDK
  2. Build the project as a module in Android studio
  3. Go to build > outputs > aar. Copy app-debug.aar into a sample Unity project
  4. Attempt to build the Unity project

The Unity build errors out in Unity because there are two ARCore modules: one from the sample module and one that Unity brings in from ARFoundation:

More than one file was found with OS independent path 'lib/armeabi-v7a/libarcore_sdk_c.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

In the build, I'd like to use the ARCore lib that is bundled with Unity's ARFoundation. The problem is if I remove the ARCore lib from the Android module, then that module doesn't build.

Is there a way to compile the ARCore sample without bundling the APCore library, then the linker can use the ARFoundation one once it's brought into Unity?

0 Answers
Related