This site has been permanently archived. The content on this site was last updated in 2019.
Quickstart for Google VR SDK for Android
Stay organized with collections
Save and categorize content based on your preferences.
Use the Google VR SDK to build apps for Daydream and Cardboard. This guide
shows you how to set up Android Studio for Google VR development and try out a
sample app.
Set up your development environment
Hardware requirements:
Software requirements:
Android Studio
version 2.3.3 or higher.
Android SDK 7.1.1 'Nougat' (API level 25) or higher.
In Android Studio, go to
Preferences > Appearance and Behavior > System Settings >
Android SDK (includes samples) to review or update installed SDKs.
The latest Google VR SDK for Android.
Open the Google VR SDK project in Android Studio
Extract the downloaded Google VR SDK into a convenient location.
Open Android Studio and select Open an existing Android Studio project.
Select the directory where you extracted the Google VR SDK.
In the Project window, review the sample gradle modules in
gvr-android-sdk > samples:
Sample |
Description |
sdk-hellovr
|
VR sample app in which you look for and collect objects.
|
sdk-controllerclient
|
Sample showing how to receive and handle Daydream controller input.
|
sdk-simplepanowidget
|
Widget to load a panoramic image from disk.
See VR View guide.
|
sdk-simplevideowidget
|
Widget to render a 360 degree video using VRVideoView .
See VR View guide.
|
sdk-video360
|
Widget to render a 360 degree video.
See video360 guide.
|
sdk-videoplayer
|
Sample activity for video playback using the Asynchronous
Reprojection Video Surface API.
See Using video viewports
in the Google VR NDK guide for more details.
|
Prepare your device
Build and run the sample app
Connect your phone to your machine using a USB cable.
In Android Studio, select Run > Run... and select the
samples-sdk-hellovr target.
Android Studio compiles and runs the application on your phone.
Put your phone into your viewer and use the app.
- Look around for the large cube.
- Daydream: Point the controller at the cube and press the touchpad
button to collect it.
Cardboard: Look at the cube and press the Cardboard button to
collect it.
- The cube moves to a new location after a button press.
The sample app shows the following core features of the Google VR SDK:
Feature |
Description |
Stereo rendering
|
App views are rendered in stereo to create a 3D effect.
|
Spatial audio
|
Sounds come from different areas of the VR world, increasing its
realism.
|
Head movement tracking
|
Users can move their heads to look around a VR world. Views update in
response to head movement.
|
User input
|
Users can interact with the app using a Daydream controller or
Cardboard button.
|
Using Google VR in your own projects
To use the Google VR SDK or NDK in your own projects, set up Google VR
dependencies.
If you are using ProGuard
in your app, add rules to ensure that it does not obfuscate any SDK or NDK code.
Setting up Google VR dependencies
Configure your project level build.gradle file:
Add Google VR SDK library dependencies in your module level build.gradle
files. You can see available libraries and their versions in
gvr-android-sdk > libraries.
As an example, review the dependencies
declared for the sample app
in gvr-android-sdk > samples > sdk-hellovr > build.gradle.
dependencies {
// Adds Google VR spatial audio support
compile 'com.google.vr:sdk-audio:1.160.0'
// Required for all Google VR apps
compile 'com.google.vr:sdk-base:1.160.0'
}
For more information, see Add Build Dependencies
in the Android Studio guide.
If you are using ProGuard to minimize your app's APK file,
make sure that ProGuard does not obfuscate any Google VR SDK or NDK code.
This makes it easier to debug stack traces in release builds.
Add the Google VR ProGuard proguard-gvr.txt
rules to your module level build.gradle file:
android {
...
buildTypes {
release {
minifyEnabled true
proguardFiles.add(file('../../proguard-gvr.txt'))
}
}
}
Next steps
To learn more about the Google VR SDK, see the following resources.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003eDevelop Daydream and Cardboard apps using the Google VR SDK with this guide, covering setup and a sample app.\u003c/p\u003e\n"],["\u003cp\u003eSet up your development environment with Android Studio, the Google VR SDK, and a Daydream-ready or Cardboard-compatible device.\u003c/p\u003e\n"],["\u003cp\u003eExplore the sample app, demonstrating features like stereo rendering, spatial audio, head tracking, and user input.\u003c/p\u003e\n"],["\u003cp\u003eIntegrate the Google VR SDK into your own projects by setting up dependencies and configuring ProGuard for optimized builds.\u003c/p\u003e\n"],["\u003cp\u003eAccess further resources for in-depth learning on Google VR development, including design principles, 6DoF tracking, and spatial audio.\u003c/p\u003e\n"]]],["To develop Google VR apps for Daydream and Cardboard, set up Android Studio with the Google VR SDK. Extract the SDK, open it in Android Studio, and explore sample modules like `sdk-hellovr`. Enable developer options and USB debugging on your device. Connect your phone, run the `sdk-hellovr` sample app, and test it in your viewer. Integrate the Google VR SDK in your projects by configuring `build.gradle` files and adding dependencies. If using ProGuard, include `proguard-gvr.txt` rules.\n"],null,["Use the Google VR SDK to build apps for Daydream and Cardboard. This guide\nshows you how to set up Android Studio for Google VR development and try out a\nsample app.\n\nSet up your development environment\n\nHardware requirements:\n\n- **Daydream:** You'll need a [Daydream-ready phone](//vr.google.com/daydream/smartphonevr/phones/)\n and a [Daydream View](//madeby.google.com/vr/).\n\n- **Cardboard:** You'll need an Android device running Android 4.4 'KitKat'\n (API level 19) or higher and a [Cardboard viewer](//vr.google.com/cardboard/get-cardboard/).\n\nSoftware requirements:\n\n- [Android Studio](//developer.android.com/studio/index.html)\n version 2.3.3 or higher.\n\n- Android SDK 7.1.1 'Nougat' (API level 25) or higher. \n In Android Studio, go to\n **Preferences** \\\u003e **Appearance and Behavior** \\\u003e **System Settings** \\\u003e\n **Android SDK** (includes samples) to review or update installed SDKs.\n\n- The latest [Google VR SDK for Android](//github.com/googlevr/gvr-android-sdk/releases). \n\nOpen the Google VR SDK project in Android Studio\n\n1. Extract the downloaded Google VR SDK into a convenient location.\n\n2. Open Android Studio and select **Open an existing Android Studio project** . \n\n Select the directory where you extracted the Google VR SDK.\n\n3. In the **Project** window, review the sample gradle modules in\n **gvr-android-sdk** \\\u003e **samples**:\n\n \u003cbr /\u003e\n\n | Sample | Description |\n |---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | **sdk-hellovr** | VR sample app in which you look for and collect objects. |\n | **sdk-controllerclient** | Sample showing how to receive and handle Daydream controller input. |\n | **sdk-simplepanowidget** | Widget to load a panoramic image from disk. See [VR View](/vr/develop/android/vrview) guide. |\n | **sdk-simplevideowidget** | Widget to render a 360 degree video using `VRVideoView`. See [VR View](/vr/develop/android/vrview) guide. |\n | **sdk-video360** | Widget to render a 360 degree video. See [video360](/vr/android/samples/video360) guide. |\n | **sdk-videoplayer** | Sample activity for video playback using the Asynchronous Reprojection Video Surface API. See [Using video viewports](/vr/reference/gvr-ndk-rendering#using_video_viewports) in the Google VR NDK guide for more details. |\n\n \u003cbr /\u003e\n\nPrepare your device\n\n- [Enable developer options](//developer.android.com/studio/debug/dev-options.html#enable)\n\n- [Enable USB debugging](//developer.android.com/studio/debug/dev-options.html#debugging)\n\nBuild and run the sample app\n\n1. Connect your phone to your machine using a USB cable.\n\n2. In Android Studio, select **Run** \\\u003e **Run...** and select the\n **samples-sdk-hellovr** target. \n\n Android Studio compiles and runs the application on your phone.\n\n3. Put your phone into your viewer and use the app.\n\n - Look around for the large cube.\n - **Daydream:** Point the controller at the cube and press the touchpad button to collect it. \n **Cardboard:** Look at the cube and press the Cardboard button to collect it.\n - The cube moves to a new location after a button press.\n\nThe sample app shows the following core features of the Google VR SDK:\n\n| Feature | Description |\n|----------------------------|--------------------------------------------------------------------------------------------------|\n| **Stereo rendering** | App views are rendered in stereo to create a 3D effect. |\n| **Spatial audio** | Sounds come from different areas of the VR world, increasing its realism. |\n| **Head movement tracking** | Users can move their heads to look around a VR world. Views update in response to head movement. |\n| **User input** | Users can interact with the app using a Daydream controller or Cardboard button. |\n\n\u003cbr /\u003e\n\nUsing Google VR in your own projects\n\nTo use the Google VR SDK or NDK in your own projects, set up Google VR\ndependencies.\nIf you are using [ProGuard](//developer.android.com/studio/build/shrink-code.html)\nin your app, add rules to ensure that it does not obfuscate any SDK or NDK code.\n\nSetting up Google VR dependencies\n\n1. Configure your project level *build.gradle* file:\n\n - Make sure that the default `jcenter()` repository location is declared.\n - Declare an Android Gradle plugin dependency: \n\n **Google VR SDK projects** : Use `gradle:2.3.3` or higher. \n\n **Google VR NDK projects** : Use `gradle-experimental:0.9.3` or higher.\n\n allprojects {\n repositories {\n jcenter()\n }\n }\n\n dependencies {\n // The Google VR SDK requires version 2.3.3 or higher.\n classpath 'com.android.tools.build:gradle:2.3.3'\n\n // The Google VR NDK requires experimental version 0.9.3 or higher.\n // classpath 'com.android.tools.build:gradle-experimental:0.9.3'\n }\n\n2. Add Google VR SDK library dependencies in your module level *build.gradle*\n files. You can see available libraries and their versions in\n **gvr-android-sdk** \\\u003e **libraries** . \n\n\n As an example, review the `dependencies` declared for the sample app\n in **gvr-android-sdk** \\\u003e **samples** \\\u003e **sdk-hellovr** \\\u003e *build.gradle*.\n\n dependencies {\n // Adds Google VR spatial audio support\n compile 'com.google.vr:sdk-audio:1.160.0'\n\n // Required for all Google VR apps\n compile 'com.google.vr:sdk-base:1.160.0'\n }\n\n For more information, see [Add Build Dependencies](//developer.android.com/studio/build/dependencies.html)\n in the Android Studio guide.\n\nConfigure ProGuard\n\nIf you are using [ProGuard](//developer.android.com/studio/build/shrink-code.html) to minimize your app's APK file,\nmake sure that ProGuard does not obfuscate any Google VR SDK or NDK code.\nThis makes it easier to debug stack traces in release builds.\n\nAdd the Google VR ProGuard [proguard-gvr.txt](//github.com/googlevr/gvr-android-sdk/blob/master/proguard-gvr.txt)\nrules to your module level *build.gradle* file: \n\n android {\n ...\n buildTypes {\n release {\n minifyEnabled true\n proguardFiles.add(file('../../proguard-gvr.txt'))\n }\n }\n }\n\nNext steps\n\nTo learn more about the Google VR SDK, see the following resources.\n\n- [Google VR SDK video and panoramic image sample app walkthrough](/vr/android/samples/vrview)\n- Learn about Google VR design and development principles in [Daydream elements](/vr/elements/overview).\n- Learn how to [enable 6DoF tracking](/vr/develop/android/get-started) in your app.\n- [Spatial audio for Android tutorial](/vr/android/spatial-audio)\n- [Google VR API Reference](/vr/android/reference_overview)\n- **Daydream:** Learn about implementing Daydream controller user interactions in your app:\n - Review the controller library in **gvr-android-sdk** \\\u003e **libraries** \\\u003e **sdk-controller**.\n - See also the [controller library API reference](/vr/android/reference/com/google/vr/sdk/controller/package-summary)."]]