To get started using ARCore with Android, you can run either the hello_ar_kotlin or hello_ar_java sample app included with the ARCore SDK. These sample apps use OpenGL, a programming interface for rendering 2D and 3D vector graphics. The apps display any detected planes and allow the user to tap on a plane to place a 3D model.
Set up your development environment
Install Android Studio version 3.1 or higher with Android SDK Platform version 7.0 (API level 24) or higher.
If you are new to Android, see Building your first Android app.
Open a sample project
In Android Studio, clone the ARCore SDK GitHub repository.
There are a number of ways to do this:
For an established Android Studio installation:
- From the Git menu, select Clone.
- In the Version control drop-down, select Git as the version control system.
- In the URL field, enter the following URL to the ARCore GitHub repository:
You can also open a Terminal and issue the
git clonecommand as follows:
git clone https://github.com/google-ar/arcore-android-sdk.git
Open one of the sample projects as follows (you must explicitly open a project in order to build and run it).
- From the File menu, select Open.
- In the arcore-android-sdk/samples folder, select either the hello_ar_kotlin or hello_ar_java folder, and click Open.
Prepare your device or emulator
You can run AR apps on a supported device or in the Android Emulator:
- In the emulator, you must sign into the Google Play Store or update Google Play Services for AR manually.
Run the sample
Make sure your Android device is connected to the development machine and click Run in Android Studio.
Android Studio builds your project into a debuggable APK, installs the APK, and then runs the app on your device. For more information, see Build and Run Your App.
You may be prompted to install or update Google Play Services for AR if it is missing or out of date. Select CONTINUE to install it from Google Play Store.
The hello_ar_java app lets you place and manipulate Android figurines on
detected AR plane surfaces. It is implemented with Android GL SurfaceView,
which is used to render the camera preview and basic AR objects such as Planes
and Anchors. hello_ar_java's sample rendering framework can be found in
Use Instant Placement
The Instant Placement API allows the user to place an AR object on the screen without having to wait for ARCore to detect surface geometry. Object placement is refined in real time as the user moves further around the environment. Once ARCore detects the correct pose in the region where the AR object is placed, the white object automatically updates to be pose-accurate, and becomes opaque.
Place a virtual object using Instant Placement
Instant Placement is automatically enabled in hello_ar_java. Tap the gear icon on the screen and choose Instant Placement in the drop-down menu. The Enable Instant Placement checkbox should already be selected.
Tap on the screen to place an object. Make sure to continue moving the device around after seeing the holographic object appear on screen, so that ARCore can get sufficient data about your surroundings to accurately anchor the virtual object.
- Try building and running other sample projects in the ARCore SDK.
- Learn how to Enable ARCore in your app.
- Use Augmented Images to build apps that can respond to 2D images, such as posters or logos, in the user's environment.
- Use Cloud Anchors to create shared AR experiences across iOS and Android users.
- Use the Depth API to ensure accurate depth for realistic and immersive user experiences.
- Use Instant Placement to quickly place AR objects on the screen.
- Review the Runtime Considerations.
- Review the Design Guidelines.