Google is committed to advancing racial equity for Black communities. See how.

Build the Cloud Anchors sample app in ARCore Extensions for Android

Use the CloudAnchors sample app to build your first AR experience that Android and iOS users can share.

Required prerequisites

Familiarizing yourself with the following concepts isn't required, but it will help you better understand how the Cloud Anchors sample app works.

Set up your development environment for Cloud Anchors

Setting up your development environment for working with the CloudAnchors sample app.

About Cloud Anchors ID sharing

Apps with Cloud Anchors capabilities need a way to share Cloud Anchor IDs between devices.

The CloudAnchors sample app uses Unity's Networking feature for sharing Cloud Anchors IDs between devices on the same network. You can use a different solution in your own apps.

Add an API Key

To use the ARCore Cloud Anchor API in your app, you'll need an API Key.

  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. Add your API key to your project:

    • In Unity, go to Edit > Project Settings > XR > ARCore Extensions.
    • Add your API key to the Cloud Anchor API Keys field.

Install and open the sample

The CloudAnchors sample is included with the ARCore Extensions package.

  1. In Unity, open the Package Manager (choosw Window > Package Manager).

  2. Select the ARCore Extensions package.

  3. In the description, click Import into Project for the Cloud Anchor sample, and wait for the files to be added to your project.

  4. In the Unity project window, open the scene located at

    Assets/Samples/ARCore Extensions/<version>/Cloud Anchor Sample/Scenes/CloudAnchors.

Configure project settings

Before building the sample, follow these steps to configure your project settings:

  1. Open the Build Settings window (File > Build Settings).

  2. In the Platform list, select Android, and click Switch Platform.

  3. To configure Android-specific Player settings, click Player Settings.

  4. Under the Player heading, specify your Name or Company Name, and set a Product Name.

  5. Under the Other Settings heading:

    1. In the Graphics APIs section, select and remove Vulkan.

    2. Uncheck Multithreaded Rendering.

    3. Select an appropriate Package Name (for example, com.<yourname>.<yourproduct>).

    4. Set the Minimum API Level to Android 7.0 ‘Nougat' (API Level 24).

    5. Set the Target API Level to Automatic (highest installed).

  6. Close the Project Settings window.

Try out the sample

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

  1. This example uses the Unity Multiplayer API. To be able to use multiplayer services, you must set up project services and set up multiplayer.

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

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

  4. In Unity, choose File > Build and Run.

    The sample app builds and launches on your phone.

  5. Create a room with the host device. The app will display a room code which can be used to join this room from another device.

  6. Move your phone around until ARCore starts detecting and visualizing planes.

  7. Tap a plane to create an anchor object on it. A host request is sent to the ARCore Cloud Anchor service. The host request includes data representing the anchor's position relative to the visual features near it.

  8. After the Cloud Anchor is successfully hosted, subsequent taps will create Star objects, which will be synchronized across devices using Unity Multiplayer Services.

  9. Launch the example from a new device, and join the room you created previously. A request is sent to the ARCore Cloud Anchor service to resolve the pose of the cloud anchor. When this request returns successfully, the sample app renders the anchor using the pose.

  10. Both devices will now be able to tap the screen to place Stars.

Next steps