Skip to main content
 首页 » 资源教程

Google VR SDK for Android(3)- Getting Started(开始)

2016年09月09日 23:43:591565640
This document describes how to get started using the Google VR for Android SDK by building and running one of our sample apps on your Android device.
本文档描述了如何开始使用谷歌的Android SDK的虚拟现实构建和运行样本应用程序在你的Android设备之一。

Treasure Hunt sample app-(寻宝示例app)

You will build the Treasure Hunt app, which uses the following features of the Google VR SDK:

您将构建寻宝游戏应用程序,它使用谷歌VR SDK的以下特点:

  • Binocular rendering: A split-screen view for each eye in VR.

    双目视觉效果:在VR 里 每只眼睛分屏视图。
  • Spatial audio: Sound seems to come from specific areas of the VR world.

  • Head movement tracking: The VR world view updates as the user moves their head.

  • Trigger input: The user can interact with the VR world by pressing a button.


In this game, you'll look around the game world to find and collect objects as quickly as possible. It's a basic game, but it demonstrates the core features of the Google VR SDK.

在这个游戏中,你会在游戏世界里快速查找和收集物体。这是一个基本的游戏,但它演示了谷歌VR SDK的核心特性。

Open and run Treasure Hunt-打开并运行寻宝游戏


Building the sample app requires:

  • Android Studio, 1.0 or higher.

  • Version 23 of the Android SDK.

  • Gradle 23.0.1 or higher. Android Studio will allow you to upgrade if your installed version is too low.

  • A physical Android device running Android 4.4 (KitKat) or higher.

Download the sample code-下载示例代码

Clone the sample app from the gvr-android-sdk GitHub repository by running the following command:

git clone

Build the sample app-编译示例程序

  1. Open Android Studio. On the Welcome to Android Studio screen, choose Open an existing Android Studio project, and select the android-sdk directory. Android Studio will display the various gradle modules on the Project tab on the left side and the various run targets on the top toolbar.

    打开 Android StudioAndroid Studio 欢迎屏幕上,选择打开一个已存在Android Studio 项目,并选择Android sdk目录。Android Studio 将显示项目的各种gradle模块选项卡左边和顶部工具栏上的各种运行目标。

  2. Connect your phone to your machine, select the samples-treasurehunt target and click Run to compile and run the application on your phone.

For more information about the code behind the Treasure Hunt game, see our explanation of it in the samples section.

更多信息背后的代码寻宝游戏,看到我们的 explanation of it in the samples section.

Start your own project

Using Android Studio

After you've read up on the Google VR SDK for Android, it'll be time to create your own applications. Here's how.

你读了之后谷歌VR Android SDK,它会创建您自己的应用程序。

  1. First, grab all the required .AAR files from the libraries folder of the sdk. To determine which .AARs you need to depend on, you can examine the build.gradle files of the various sample 

    apps. For example,samples/treasurehunt/build.gradle's dependency section has the following entries:

    dependencies {
      compile project(':libraries-audio')
      compile project(':libraries-common')
      compile project(':libraries-core')

    This indicates that an application similar to the Treasure Hunt sample needs the audiocommon, and core libraries.

  2. Create new modules for each of these libraries. Using Android Studio's GUI, this can be done via File -> New -> New Module. Select Import .JAR/.AAR Package. Locate one of the .AARs and import it.

  3. Then add this new module as a dependency to your main app via File > Project Structure > Modules (on the left side's section list) > YOUR APP's MODULE NAME > Dependencies (on the right side's tab list) -> '+' -> Module Dependency.

Once this is done for all of the required libraries, you will be able to reference code in the Google VR SDK in your app.

Directly using Gradle

Using the steps above will cause Android Studio to generate new modules and edit your .gradle files automatically. Alternatively, you can directly include the .AARs in your application's module by editing that specific module's build.gradlefile and adding the following entries:

dependencies {
  compile(name:'audio', ext:'aar')
  compile(name:'common', ext:'aar')
  compile(name:'core', ext:'aar')

    dirs 'libs'

This will tell Gradle to look in the libs subdirectory of your module for the three .AARs. Create that libs subdirectory inside your module's directory and copy the .AARs there. You will need to repeat this for every module that uses those .AARs which will lead to many duplicate .AARs as your project becomes more complex.