Table of contents
1.
Introduction
2.
Steps Involved
2.1.
AR Required or AR Optional
2.2.
Add entries to your manifest.xml file.
2.3.
Addition of build dependencies
2.4.
Performing Runtime Checks
2.5.
User Privacy Requirements Compliance
3.
FAQs
4.
Conclusion
Last Updated: Mar 27, 2024
Easy

Enabling ARCore

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

ARCore is google’s one of the best platforms to build and deploy AR-experienced applications. ARCore provides different APIs that enable your phone to understand your phone environment and react according to the information that got from the environment. ARCore mainly provides three capabilities as Motion Tracking - which makes the phone understand and track its position relative to the earth, Environmental Understanding - which makes your phone understand the environment and interact with it, Light Estimation - estimates the current lighting conditions. We will learn more about the ARCore, and how to enable and use it on our devices.

Steps Involved

In Order to enable ARCore on our app, we need to follow the below steps:

Step 1 - > For your app, choose between AR Required and AR Optional.

Step 2 - > Add the above-selected entries to your app manifest.

Step 3 - > Add Build Dependencies to your project or app.

Step 4 - > Perform runtime checks such as whether the device supports ARCore or not, Camera Permissions are granted or not, etc.

Step 5 - > To make sure your app complies with ARCore’s User Policy Requirements.

AR Required or AR Optional

AR Required: An AR Required App must run only with ARCore enabled. It won't work without ARCore.To use this AR Required app, the device must be ARCore Supported device, and it has Google Play Services for AR installed.
AR Optional: On the other hand, the AR Optional Apps function differently. They provide different functionalities. Here these devices have optional AR features that enable only when the device supports AR, and the app has Google Play Servies for AR installed in it.
You can learn more differences about these through this link.

Add entries to your manifest.xml file.

Modify the manifest.xml file with the below code:
For AR Required:

<uses-permission android:name="android.permission.CAMERA" />
<!-- Limits app visibility in Google Play Store to ARCore supported devices

     (https://developers.google.com/ar/devices). -->

<uses-feature android:name="android.hardware.camera.ar" />
<application …>
	 …
	<!-- "AR Required" app, requires "Google Play Services for AR" (ARCore)

         to be installed, as app does not include any non-AR features. -->

    <meta-data android:name="com.google.ar.core" android:value="required" />

</application>

For AR Optional:

<uses-permission android:name="android.permission.CAMERA" />
<!-- If your app was AR Required, don't forget to remove the

     `<uses-feature android:name="android.hardware.camera.ar" />` entry, as

     this would limit app visibility in the Google Play Store to only

     ARCore supported devices. -->

<application …>
	…
	 <!-- "AR Optional" app, contains non-AR features that can be used when

         "Google Play Services for AR" (ARCore) is not available. -->

    <meta-data android:name="com.google.ar.core" android:value="optional" />

</application>

And maintain at least minimum SDK versions. For AR Required, it should be a minimum 14th version, and for AR Optional, it should be at least the 24th version..

Addition of build dependencies

To add ARCore to your project, make sure your build-gradle file contains Google Maven Repo as 

allprojects {
    repositories {
        google()
        …
    }
}

And add the latest ARCore library as 

dependencies {
    …
    implementation 'com.google.ar:core:1.30.0'  }

Performing Runtime Checks

To check whether ARCore is supported or not, both AR Required and AR Optional use a method called ArCoreApk.checkAvailability() to check if the ARCore is supported or not. Some AR not supported devices may install Google Play services for AR from the external resources, this will also be checked by this method whether the resource is an unknown resource or not. It will return UNKNOWN_CHECKING in that case.
To request Camera Permissions, we need to take help from the CameraPermissionHelper class that is built to access permissions for the camera.

User Privacy Requirements Compliance

Make sure every app that is designed to use ARCore satisfies User Privacy Requirements.

FAQs

  1. How do I disable AR on a device that doesn’t support ARCore?
    The device on which the ARCore is not supported, that app should disable AR-related functionality and hide the UI elements associated with it. Thus this results in disabling AR on a device.
  2. How do I make an app AR required?
    AR Required apps won’t run without AR. It must enable AR in it. To make an app AR Required, move to EDIT - > PROJECT SETTINGS - > PLUGINS - >GOOGLE AR CORE and check the unchecked box aside to AR Required. 
  3. How to enable AR on my app?
    To enable AR on your app, you need to follow the five steps discussed in this article. Like choosing between AR Required and AR Optional, modifying the manifest file, adding dependencies, performing runtime checks, and complying with User Privacy Requirements.
  4. How do I make an app AR Optional?
    AR Optional apps run even without AR, they are only enabled when the device supports AR, and the device has Google Play Services for AR installed. To make it AR Optional, move to EDIT - > PROJECT SETTINGS - > PLUGINS - > GOOGLE AR CORE and uncheck the box aside AR Required.
  5. What is the minsdkversion for ARCore?
    For AR Optional app, the minimum SDK version is 14 and for AR Required app, the minimum SDK version is 24.

Conclusion

In this article, we have briefly discussed the AR Core and how to enable it to make your device AR applications. We have discussed all the five steps in doing the same. Please have a look at this and this link for more information. You can explore more about these in Google developer blogs.
Hey Ninjas! You can check and explore more unique courses on machine learning concepts through our official website, Coding Ninjas, and checkout Coding Ninjas Studio to learn through articles and other important stuff to your growth.
Happy Learning!

Live masterclass