Building ARDK Apps for Android

Use the following steps to build and deploy your ARDK app to Android devices.

Prerequisites

You should have a Unity project configured with the ARDK package, as described in Adding ARDK to Unity.

Your Unity project should have a Authentication asset configured with your API token, as described in Authentication.

You should have an Android device compatible with ARDK. See “Runtime Requirements” in System Requirements for a list of compatible Android devices and minimum Android versions.

Steps

  1. Open the External Tools window (Unity> Preferences) to specify your Android SDK and NDK paths. It is recommended to select the Use embedded JDK option.

../../_images/ExternalTools.png
  1. Access the Build Settings (menu: File> Build Settings).

../../_images/BuildMenu.png

Change the Company Name to your organization’s name. Then navigate to the Android> Other Settings pane to specify your build settings.

../../_images/BuildSettings.png

Under the Rendering section, uncheck the Auto Graphics API setting, and remove the Vulkan renderer if it is present. ARCore and Vulkan will not work together.

../../_images/AndroidGraphics.png

For Scripting Backend choose IL2CPP. Choosing Mono may cause crash issues when using awareness features.

For Target Architectures select both ARMv7 and ARM64. Note that ARCore does not support running 32-bit only apps on some 64-bit devices.

Some other settings and their effects on your application:

Multithreaded Rendering

Enable this option to use multithreaded rendering. Both enabling and disabling this option is supported by ARDK.

Package Name

Set the application ID, which uniquely identifies your app on the device and in the Google Play Store.

Minimum API Level

Android 5.0 ‘Lollipop’ (API level 21)

Minimum Android version (API level) required to run the application.

Target API level

Automatic (highest installed)

Target Android version (API level) against which to compile the application.

  1. Back in the Build Settings window, the Example/StarterScene should be automatically added and checked inside the Scenes In Build box. If it is not checked, find the scene in the Unity Project window and drag it into the box.

../../_images/Scenes.png
  1. Connect your Android device to your computer, and click the Build and Run button. Save the build to your desired location and click Save. The app should automatically open on your phone after a short time.

../../_images/BuildAndRun.png

Building for Android 11 (API level 30) and higher

In Android 11, Google enforced a limit on what you can query about other apps on the device. Now you can only query for the existence of apps you specifically referenced in your manifest. This breaks ARDK as it doesn’t include this new manifest tag. This new security policy is only applied to apps built targeting API level 30 or above.

If you’re using Unity 2019 and need to build and run your ARDK project on Android API level 30 or higher, you need to install gradle v5.6.4 or higher and configure your Unity project to use this version of gradle. Follow the steps at https://developers.google.com/ar/develop/java/enable-arcore for your version of Unity.

Additionally, for Unity 2019 and Unity 2020, you’ll need to provide a custom AndroidManifest.xml that adds the query tag for ARCore by doing the following:

  • Add a custom AndroidManifest.xml to your Unity project. You may need to do an initial Android build in Unity, and then copy the generated AndroidManifest.xml in your project’s Temp/gradleOut/unityLibrary/src/main/ to your project’s Assets/Plugins/Android directory. More details on how Unity builds generate the Android manifest are available here: https://docs.unity3d.com/Manual/android-manifest.html.

  • Edit the custom AndroidManifest.xml and add a <queries> <package android:name="com.google.ar.core" /> </queries> section. Your AndroidManifest.xml might look something like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
  <application>

    ...various activity, intent, meta-data tags...

  </application>

  ...various uses-feature and uses-permission tags...

  <queries>
    <package android:name="com.google.ar.core" />
  </queries>
</manifest>
  • Build with the new gradle configuration, custom gradle templates, and custom AndroidManifest.xml.