Log in or register to post comments

Native ARCore functionality

December 29, 2018 - 5:14am #1

Hello,

I'm using Vuforia Fusion with ARCore 1.6.0. I need to check, if the user has ARCore capable device to enable some ARCore specific functionality. I didn't find a solution using Vuforia SDK so I need to access ARCore library directly. I use following method:

var jc = new AndroidJavaClass("com.google.ar.core");
jc.Call<bool>("ArCoreApk.Availability.isSupported"); 

This works fine in the Unity editor, however if I run the app on the Android device, it throws "ClassNotFoundException" in the first line. It's like the .aar file (core-1.6.0.aar) where is that class is not included in the build for some reason. I'm not sure what I'm doing wrong here.

 

Thanks for your tips.

Native ARCore functionality

January 5, 2019 - 5:49am #3

I was thinking of using getActiveFusionProvider() method, but I would still need to call some native ARCore stuff to check, if it is installed and request the install if not.

 

However I've figured it out in the meantime :). I used the native api calls wrong before. For those who run into the same problem, the correct usage should be as follows:

AndroidJavaClass arCoreApk = new AndroidJavaClass("com.google.ar.core.ArCoreApk");
AndroidJavaObject arCoreApkInst = arCoreApk.CallStatic<AndroidJavaObject>("getInstance");
AndroidJavaObject arCoreApkAvailability = arCoreApkInst.Call<AndroidJavaObject>("checkAvailability", context);
bool isSupported = arCoreApkAvailability.Call<bool>("isSupported");

Then it's possible to request ARCore to install by calling this:

if (isSupported)
{
     Debug.LogWarning("Requested install of ARCore");
     arCoreApkInst.Call<AndroidJavaObject>("requestInstall", context, isSupported);
}

So now if the device supports ARCore and it is not installed or outdated, it will offer to install.

Native ARCore functionality

January 2, 2019 - 3:27pm #2

Hello,

I wonder if this ARCore API call is failing due to Vuforia being attached to the camera. The device camera is a singleton, so if ARCore's API requires being attached to the camera, the issue you're seeing may be related to Vuforia using the camera. Just a thought...

FYI Vuforia provides APIs to query whether a device supports Fusion features. Use getActiveFusionProvider() to query the device's capabilities. If the device returns FUSION_PROVIDER_VUFORIA_VISION_ONLY, then it does not support Ground Plane (and Fusion). The caveat here is that an earlier call to setActiveFusionProvider() can mask the device's actual capabilities if they are set to new values after Vuforia init.

You can find API documentation here: https://library.vuforia.com/getting-started/overview.html. Code examples can be found in our Core Samples on the Asset Store.

Thanks,

Vuforia Engine Support

Log in or register to post comments