Building the ARDK-Getting-Started App for Android

How to build the ARDK Getting Started app for Android.

Steps

1) Check System Requirements.

2) Download the SDK to your desired location.

3) Download the ARDK-Getting-Started Unity Project to your desired location

4) Open Unity Hub, click the Add button and browse to the folder you downloaded in step 3.

5) Select Android as the target platform and click the project to open it in Unity.

6) Don't be alarmed if you see errors about missing ARDK namespaces. Follow these steps to import ARDK into the project.

7) 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.

8) Access the Build Settings (menu: File > Build Settings).

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

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.

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:

Setting Value Function
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. Recommended Value.


9) 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.

10) 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.

11) Now that you've got the sample app running, check out the User Manual to learn more about how to integrate ARDK features into apps of your own!

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, 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.