Skip to content

Android

XRTracker on Android uses Injected mode with AR Foundation and ARCore. The AR Foundation camera feeder captures frames from the device camera and feeds them to the tracker each frame.

Requirements

Requirement Details
Unity Packages AR Foundation 6.x+, Google ARCore XR Plugin
Architecture ARM64
Scripting Backend IL2CPP (recommended) or Mono
Minimum API Level Android 7.0 (API 24)+
Native Library Shared library (.so, ARM64)
Device Requirement ARCore must be installed (Google Play Services for AR)

Setup

1. Install AR Foundation Packages

In the Unity Package Manager, install:

  • AR Foundation (6.x or later)
  • Google ARCore XR Plugin

2. Configure XRTrackerManager

  1. Set Image Source to Injected
  2. Add an AR Session and XR Origin to your scene (standard AR Foundation setup)
  3. The AR Foundation camera feeder handles frame delivery automatically

3. Player Settings

In Edit > Project Settings > Player > Android:

Setting Value
Minimum API Level 24 (Android 7.0)
Target Architecture ARM64
Scripting Backend IL2CPP
Internet Access Required (for ARCore installation prompt)

Note

IL2CPP is recommended for production builds due to better performance. Mono works for development but has higher runtime overhead.

ARCore Device Compatibility

ARCore is required on the device. Not all Android devices support ARCore.

  • Check the ARCore supported devices list for compatibility
  • If ARCore is not installed, the user is prompted to install Google Play Services for AR
  • Your app should handle the case where ARCore is unavailable

Warning

Test on physical devices early. ARCore availability and performance vary significantly across the Android ecosystem.

Depth Tracking

Depth is available on devices with a Time-of-Flight (ToF) sensor or via ARCore's software depth estimation:

  • Hardware ToF: Samsung Galaxy S20+/Ultra, Galaxy Note 20 Ultra, Huawei P30 Pro, and others
  • ARCore Depth API: Software-based depth estimation available on most ARCore devices (lower quality than hardware ToF)

To enable depth:

  1. Add an AROcclusionManager component to the AR Camera
  2. Enable Depth Tracking on each TrackedBody that should use depth
  3. The AR Foundation feeder passes depth frames to the tracker automatically

Tip

Hardware ToF sensors provide significantly better depth quality than ARCore's software depth. For best results with depth tracking, target devices with ToF sensors.

Camera Intrinsics

AR Foundation provides per-frame camera intrinsics from ARCore. No calibration file is needed -- intrinsics are passed to the tracker with each frame automatically.

Build & Deploy

  1. File > Build Settings -- switch platform to Android
  2. Ensure Build System is set to Gradle
  3. Connect your device via USB with USB debugging enabled
  4. Click Build and Run

Performance Tips

  • CPU budget: Tracking runs on the CPU. On mid-range Android devices, expect 4-8ms per tracked body. Monitor with the Unity Profiler.
  • Avoid debug logging: Native M3T logging (M3TLog) is expensive on Android (~5-10ms overhead). Ensure debug logging is disabled in production builds.
  • Reduce tracked bodies: Each active TrackedBody adds to per-frame cost. Disable bodies not currently in view.
  • IL2CPP: Use IL2CPP for production -- it provides measurably better performance than Mono on Android.
  • GPU shaders: If using edge tracking with the Vulkan renderer, ensure the device supports Vulkan. Most ARCore-compatible devices do, but some older devices fall back to OpenGL ES.

Troubleshooting

Issue Solution
Black camera feed Ensure camera permission is granted. Check AndroidManifest.xml includes android.permission.CAMERA.
ARCore not found Device may not support ARCore. Check the supported devices list.
Tracking jitter Verify the device is ARCore-compatible. Low-end devices may not provide stable enough camera feeds.
App crashes on startup Check minimum API level is 24+. Ensure ARM64 architecture is selected (not ARMv7).