CloudXR SDK with Unity

I am trying to create Android App for Oculus Quest2 with CloudXR SDK and unityLibrary which is exported as a library for Android.

When I launch application, it throws me an error as:

JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "vrapi_UpdateFoveation" referenced by "/data/app/com.nvidia.cloudxr.ovr-63zV9gHGa5kcOiDbIcKtww==/lib/arm/libOVRPlugin.so"
at void java.lang.Runtime.loadLibrary0(java.lang.ClassLoader, java.lang.Class, java.lang.String) (Runtime.java:1071)
at void java.lang.Runtime.loadLibrary0(java.lang.Class, java.lang.String) (Runtime.java:1007)
at void java.lang.System.loadLibrary(java.lang.String) (System.java:1667)
at void com.unity.oculus.OculusUnity.loadLibrary(java.lang.String) (OculusUnity.java:81)
at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.Class) (Runtime.java:-2)
at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:1115)
at void java.lang.Runtime.load0(java.lang.Class, java.lang.String) (Runtime.java:936)
at void java.lang.System.load(java.lang.String) (System.java:1631)
at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:103)
at void android.os.Looper.loop() (Looper.java:214)
at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)

  in call to GetStaticMethodID
  from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.Class)

How can I solve this issue??

Thank you for your cooperation.

Hi,

this is because the resulting APK does not contain the libOVRPlugin.so file, to solve this you need to modify the build.gradle from your app’s module and from the unity module as follows:

Unity buil.gradle:
change implementation (name: ‘. OVRPlugin.aar’, ext:‘aar’) for compileOnly files(‘libs/OVRPlugin.aar’)

and in the app’s build.gradle add this line implementation files(‘path-to-unity-build/unityLibrary/libs/OVRPlugin.aar’)

Within Android Studio you can analyze any APK, AAR file, use that tool to ensure the build artifact contains all the required files.

Be aware that you might have incompatibilities due to the different Oculus SDK versions (native vs Unity), also you can not run the Unity player in the same process as the CloudXR client.