Cloud Anchors for Android NDK Quickstart

Get started with Cloud Anchors. This guide shows you how to:

  • Set up your development environment for Cloud Anchors
  • Try out hosting and resolving anchors in the Cloud Anchors sample app

If you are new to working with anchors, see Working with anchors for an introduction.


Cloud Anchor capabilities and a sample app are included in the ARCore SDK for Android NDK.

This guide assumes that you have already installed and configured the ARCore SDK for Android NDK. If not, see the Quickstart for Android NDK for installation and setup instructions.

Use Cloud Anchors

Set up your development environment for working with Cloud Anchors and try out the sample app.

Open the sample app in the SDK

The helloarcloudanchor sample app is included with the ARCore SDK for Android NDK.
In Android Studio, you can find it under:

Set up anchor ID sharing

The sample app uses Firebase for sharing Cloud Anchor IDs between devices. You can use a different solution in your own apps.

Set up Firebase storage in the sample app for sharing anchor IDs between user devices:

  1. Follow steps 1 through 5 in the Firebase instructions for manually adding Firebase to your app.
  2. Download the google-services.json file generated as part of adding Firebase to your app.
  3. In Android Studio, add the google-services.json file to your project's module folder. Typically, this is the app/ folder.

Add an API Key

To use Cloud Anchors, you'll need to add a Google ARCore Cloud Anchor API Key to your app.

  1. Obtain an API Key. See Setting up API keys in the Google Cloud Platform Console Help Center if you are new to working with API keys.

  2. Enable the ARCore Cloud Anchor API for your Google Cloud Platform project.

  3. In Android Studio, add your ARCore Cloud Anchor API key to your project. To do this, include the API key in the following code and add it to app/manifests/AndroidManifest.xml:


Try out the sample app

Build and run the helloarcloudanchor sample app to try out hosting and resolving Cloud Anchors.

  1. Make sure that developer options and debugging are enabled on your phone.

  2. Connect your phone to your development machine via USB.

  3. In Android Studio, click Run. Select your device as the deployment target and click OK.

    The sample app launches on your phone and ARCore starts detecting planes in front of your camera.

  4. Once planes are detected, tap your phone screen to place an anchor on a plane.

  5. Tap the HOST button to host the anchor.

    A host request is sent to the Google ARCore Cloud Anchor API. This request includes visual features and IMU readings representing the anchor's position. Once the anchor is hosted, it is assigned an ID that is used for resolving Cloud Anchors in this space.

    The app displays a room code after the hosting request succeeds. You can use the code to access previously hosted anchors for this room, using the same device or another device.

  6. Tap RESOLVE and enter a previously returned room code to access hosted anchors for this room.

    A resolve request is sent to the Google ARCore Cloud Anchor API, returning the IDs of anchors currently hosted in the room. The sample app uses these IDs to render 3D objects attached to the hosted anchors.

Next Steps