[ARFoundation] Support Device check on android does not work correctly

I wanna make AR and non AR version for android with AR Foundation
(Unity 18.3 ,ARF-1.5 prev.5, ARCore -2.1 p.5, ARKit - 2.1 p.5 as well )
So i want to check platform is supporting AR or not for implimintation diffrent logics .
I tried to use sample for device support check About AR Foundation | AR Foundation | 2.1.19
on Non AR scene.
But anyway on devices that have android version 7 whitch are not support ARCore every launch it
redirect to play market to instal ARCore despite it is dont support it. Only then i close redirect tab it say that device dont support but this redirect happens every launch.

Devices : xiaomi redmi 6a and Huawei Y9 2018.
Also i tried to turn off attemp update option and in project settings make ARcore+Arkit is optional.
Anyone know a solution?

Also getting this problem on Samsung Galaxy S6, Android version 7.0, Unity 2018.4.3f1, AR Foundation 1.5.0-preview.5, AR Core plugin, 2.1.0-preview.5.

Same problem with me, are there any solution?

As Google Play Services for AR is automatically installed and updated on supported devices you can check if ARCore is supported this way.

        public static bool IsARCoreSupported()
{
            var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            var context = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            var packageManager = context.Call<AndroidJavaObject>("getPackageManager");
            AndroidJavaObject packageInfo = null;
            try
            {
                packageInfo = packageManager.Call<AndroidJavaObject>("getPackageInfo", "com.google.ar.core", 0);
            }
            catch
            {
 
            }
            if (packageInfo != null)
                return true;
            else
                return false;
        }

Also you can use ARSupportChecker plugin that does exactly that stuff:

ARSupportChecker.IsSupported()

In my experience, there is no guarantee that ‘Google Play Services for AR’ is installed on supported devices automatically. Also, a user can remove this service manually. In these cases, your script will produce a false negative result.

I prefer to use this AR Foundation API to determine the support. It will work correctly only if ARCore is set to ‘Optional’ in XR Plug-in Management.

using System.Collections;
using UnityEngine;
using UnityEngine.XR.ARFoundation;


public class CheckAvailability : MonoBehaviour {
    IEnumerator Start() {
        yield return ARSession.CheckAvailability();
        Debug.Log($"ARSession.CheckAvailability() finished with state: {ARSession.state}");
    
        // ARSession.CheckAvailability() can finish with state ARSessionState.Installing if an update for AR Services is required. So we wait.
        while (ARSession.state == ARSessionState.Installing) {
            yield return null;
        }
    
        if (ARSession.state == ARSessionState.NeedsInstall) {
            Debug.Log("Installing AR provider...");
            yield return ARSession.Install();
        }
    
        Debug.Log($"AR is supported in this device: {ARSession.state >= ARSessionState.Ready}");
    }
}

The method with ARSession.CheckAvailability() returns false positive result on some devices and redirects devices that are not supported AR to the Google Play, what is frustrated for users. You can see such behaviour on Redmi Note 5 and some other Xiaomi devices. On the other hand on the most devices this package is undeletable and preinstalled.

I can only reproduce this redirection if ARCore is set to Required. Are you sure you’ve tested my method with ARCore set to Optional on Redmi Note 5?

Yep, AR Core is Optional, it’s reproducible on Redmi Note 4 and Redmi Note 5.

1 Like