Start Building Daydream Apps: Exploring Google VR SDK

Published Dec 02, 2016Last updated Jan 18, 2017

As usual, this year’s Google I/O conference saw a whole host of announcements and product launches. And with the buzz currently surrounding virtual reality, it was no surprise that one of these announcements was VR-related: enter Daydream, Google’s new mobile VR platform.

Fast forward a few months and the Google VR SDK with Daydream support has graduated out of beta and the first Daydream-ready smartphones are starting to hit the market — basically, it’s the perfect time to take a closer look at Google’s brand-new VR platform!

In this article, I’m going to show you how to setup a DIY development kit, so you can get that all-important hands-on experience with the Daydream platform—even if you haven’t managed to get your hands on the Daydream View or the Daydream Controller yet!

I’ll also be showing you how to setup this first official release of the Google VR SDK, and how to create a Daydream-ready Android project that’ll provide the perfect starting point for developing your own Daydream apps.

And finally, since a brand new platform means a brand new set of best practices, we’ll also take a quick look at some of the guidelines you need to keep in mind when developing for the Daydream platform.

Developing for Daydream: What you’ll need

If you’re going to develop anything for Daydream, then you need to be able to run Daydream apps. Not only is this essential for testing any Daydream apps you do create, but as a brand new platform the more time you can spend exploring everything that Daydream has to offer, the better — and one of the easiest (and most fun) methods is to spend some time playing around with virtual reality games.

Officially, if you want to run Daydream apps then you’ll need the following:

  • A VR viewer, specifically Daydream View.
  • The Daydream controller. This controller can track rotation and orientation, and includes a touchpad and buttons that allow you to interact with Daydream apps. This controller is sold as part of a package with the Daydream View.
  • A Daydream-ready smartphone. At the time of writing, only the Google Pixel and the Nexus 6P were compatible with Daydream.

But don’t worry if you haven’t got your hands on the dedicated viewer and controller just yet, as you don’t actually need either the Daydream View or the Daydream controller in order to run Daydream apps.

Perhaps you’ve placed your order for the Daydream hardware but are still waiting for your package to arrive; maybe you plan on placing your order soon (post-payday, perhaps?) or maybe you simply want to see what Daydream is all about before you invest £69.00 in a dedicated controller and viewer.

Whatever the reason, if you don’t currently have access to the Daydream controller and Daydream View, then I’m going to show you how to setup a DIY Daydream development kit that enables you to experience this platform regardless.

The major drawback is that you will need two Android smartphones, but one of these devices can be running KitKat or above, so if you have an old smartphone hanging around then now’s the perfect time to bring it out of retirement.

In order to cook up your own development kit, you’ll need the following:

  • A Daydream-ready “headset” phone. At the time of writing, only the Google Pixel and Nexus 6P meet this criteria.
  • A “controller” phone. An Android phone running KitKat or above. This is what you’ll be using instead of a Daydream controller.
  • A Cardboard-compatible VR viewer. You can use the viewer of your choice, as long as it plays nicely with Cardboard.
  • The Google VR SDK for Android. Head on over to the Google VR Downloads page, click ‘Clone or download’ and select “Download ZIP.” Unzip the file.

Finally, you’ll need a Daydream app. I’m going to use Google’s “Treasure Hunt” sample app, as it demonstrates many of the core features of Daydream, so if this is your first hands-on experience with the platform then Treasure Hunt provides a great introduction.

To build and run the Treasure Hunt sample app, you’ll need the following:

  • Android Studio 1.0 or higher.
  • Version 23 of the Android SDK.
  • Gradle 23.0.1 or higher.
  • An Android device running 4.4 or higher.

1. Build and install the Treasure Hunt app

Our first task is building the Treasure Hunt app and installing it to our headset device:

  • Head over to gvr-android-sdk and download Treasure Hunt as a ZIP file. Unzip it, then launch Android Studio and open the unzipped gvr-android-sdk folder as a new Android project.
  • Grab the phone you’re using as your Daydream headset and make sure it has “USB Debugging” enabled. If USB debugging isn’t enabled, open the device’s “Settings” app, select “Developer options” and set the “USB debugging” slider to the “On” position.
  • Connect your Android device to your development machine.
  • Select “Run” from the Android Studio menu bar, followed by “Run…” Select “samples-sdk-treasurehunt,” and then click “Run” again.

daydream apps
android studio run

  • Once Treasure Hunt has been installed on your Android device, launch it and grant it any permissions it requests.
  • If you haven’t already, download the Cardboard app from the Google Play store. Launch this app and grant any permissions it requests.
  • Reboot your device.

2. Install the Controller Emulator APK

As already mentioned, we’re going to use the second Android device as our Daydream controller, by installing the Controller Emulator app:

  • Grab the Controller Emulator APK from GitHub (note, this is a direct download link). Move this APK to your Android device.
  • In order to install apps from APKs, you’ll need to have “Unknown sources” enabled, so open your device’s “Settings” app, select “Security” and then push the “Unknown sources” slider to the “On” position.
  • Launch any file explorer app, such as ES File Explorer, and navigate to the Controller Emulator APK.
  • Give this APK a tap, then follow the onscreen instructions to install.
  • Launch your new Controller Emulator app and tap “Next.” Read the onscreen information, then tap “Finish.”

3. Set up the headset phone

You’ll now need to enable several settings on the phone you’re using as your headset:

A. Enable the Google VR Services permissions

  • Launch your device’s “Settings” app.
  • Select “Applications.”
  • Tap the three-dotted menu icon.
  • Select “Google VR Services” from the list of apps.
  • Select “Permissions” and enable all the permissions that appear in this list.

B. Turn on special access for Google VR Services

  • Navigate back to the main “Settings” screen.
  • Select “Applications.”
  • Tap the cog icon in the upper-right corner.
  • Select “Special access.”
  • Enable Google VR Services for the following: Do Not Disturb access; VR helper services, and Notification access.

C. Enable Bluetooth and Location services on both devices

  • Navigate back to the main “Settings” screen.
  • Select “Bluetooth” and make sure the “Bluetooth” slider is set to “On.”
  • Navigate back to the main “Settings” screen.
  • Select “Location” and make sure “Location” is set to “On.”
  • Select “Mode” and choose “High accuracy.”
  • Make sure Bluetooth is enabled on the phone you’re planning to use as your Daydream controller (Settings > Bluetooth > On).
  • Pair your headset phone and your controller phone over Bluetooth, by selecting “Settings > Bluetooth” on either phone and waiting for it to detect the other device.
  • Tap the device you want to connect to, and then confirm the pairing when prompted.

D. Setup your Controller Device — and connect!

On the headset phone, launch the Treasure Hunt app you installed earlier, then:

  • Give the cog icon a tap in the app’s upper-right corner.
  • Select “Settings,” followed by “Setup.”
  • Tap the “Version” item 7 times to reveal the “Developer Options.”
  • Select “Controller emulator device.”
  • Select the phone you’re using as your Daydream controller.
  • Close the Treasure Hunt app completely.

You’re now ready to check that your DIY development kit works:

  • On your headset phone, re-launch the Treasure Hunt app.
  • On your controller phone, launch the Controller Emulator app.

If everything is set up correctly, you’ll see ‘Connected’ at the top of the Controller Emulator app. At this point, you can interact with the Treasure Hunt app on your Android headset, using your second Android device as a Daydream controller.

From top-to-bottom, the Controller Emulator consists of:

daydream apps
Touchpad area (large circle). This emulates the Daydream controller’s touchpad area. On a real controller, the user can also “click” the touchpad by pressing it; to mimic this action in the Controller Emulator app, double-tap the touchpad area. When designing Daydream apps, you’ll typically map this “click” event to your app’s primary action.

App buttons (immediately below the touchpad). You’ll typically use this button for your app’s secondary actions.

Home button (bottom). This button is reserved for system use, so you can’t use it in your app.

Place your headset phone in your Cardboard-compatible viewer, and you’re ready to go! Since Treasure Hunt demonstrates many of the core Daydream features in action, it’s recommended that you spend some time playing around with this game — particularly if this is your first hands-on experience with Daydream.

Starting your own Daydream project

Once you’ve spent some time exploring the Daydream platform, you may want to start developing your own Daydream apps.

Guiding you through the process of designing and developing a complete VR experience is beyond the scope of this article, so instead I’m going to cover the essentials of creating a Daydream-ready project that you can continue to build on, and potentially develop into your own Daydream app.

Create a new Android project, and let’s get started!

1. Importing Libraries

The Google VR SDK is packaged as a set of .AARs instead of jars, so the first step is importing all the .AARs you want to use in your project. You’ll find all the available .AARs in the gvr-android-sdk-master folder you downloaded earlier.

Exactly which .AAR libraries you need to import will vary depending on the kind of app you’re creating, but the process is always the same:

  • Select “File” from the Android Studio menu bar, followed by “New” and “New Module…
  • Select “Import .JAR/.AAR Package.” Click “Next.”
  • Click the little dotted button to the right of the “File name” field.
  • Navigate to the “gvr-android-sdk-master” folder you unzipped earlier.
  • Double-click “libraries.”
  • Find the library you want to import and select its .AAR file.

daydream apps
Select .AAR file

  • Click “OK,” followed by “Finish.”
  • Add this module as a dependency by selecting “File,” from the Android Studio menu bar, followed by “Project Structure…”
  • In the “Project Structure” window, select the module you want to use.
  • Click the little “+” towards the bottom-left of this window, and then select “Module dependency” from the dropdown that appears.
  • Select your app and click “OK.” When prompted, click “OK” again.
  • Open your module’s build-gradle file and reference the .AAR file in the dependencies block, for example:
    dependencies {
       compile project(":audio")

Repeat this process for every library you want to use in your project, and then perform a Gradle sync.

2. Embedding VR View

At its most basic, a VR app is a 360-degree image or video that you embed in your Android app via a new component known as a “VR view.”

Android’s new VR view component supports mono and stereo 360-degree images and videos, in the equirectangular-panoramic (equirect-pano) format — but how do you generate this content?

If you want to capture 360-degree content from the real world, then you’ll either need to use a camera that produces VR-compatible content, such as the Ricoh Theta camera or use the Cardboard Camera App and then reformat your content using Google’s conversion tool.

You can also use CGI software to generate 360-degree images and videos. Some popular options include the 360 Panorama Capture plugin for Unity, the Domemaster3D fulldome lens shader for Maya, and Unreal Engine 4, which has built-in support for capturing 360-degree content.

Once you have your image or video content, open the layout file where you want to display this content and add one of the following VR view elements:

  • google.vr.sdk.widgets.pano.VrPanoramaView, if you want to display a 360-degree image.
  • google.vr.sdk.widgets.pano.VrVideoView, if you want to display a 360-degree video.

You can then style this view using Android’s regular XML attributes, for example:

          android:layout_height="200dip" />

If you’re displaying an image, then open the corresponding Activity and tell the system which image it should load, using the VrPanoramaView.loadImageFromBitmap attribute.

If you want to display a 360-degree video instead, then you’d add a element to your layout resource file, and then open the corresponding Activity and tell the system which video it should load, using the loadVideoFromAsset attribute, for example:

    videoWidgetView.loadVideoFromAsset("myVRVideo.mp4", options);

The Google VR SDK for Android comes with two sample apps that demonstrate how you can use VR view to display 360 images (Simplepanowidget) and 360 video (Simplevideowidget). You’ll find both of these samples in your unzipped “gvr-android-sdk-master/samples” folder. If you want to take a closer look at either of these apps, then simply open them as a new Android project in Android Studio.

Finally, you’ll need to make some changes to your project’s Manifest. Regardless of the kind of VR app you’re creating, you should request the following permissions:

  • <uses-permission android:name="android.permission.NFC" /> allows the Google VR to access the VR viewer’s NFC tag, so your app will know when the user has placed their device in a compatible handset.
  • <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> the Google VR SDK requires this permission in order to pair the user’s phone with their VR viewer.

Next, find the section of your Manifest where you declare the Activity that’ll contain your VR content, and make the following additions:

    //Specify that this Activity must run in landscape mode, which is a requirement of all VR content.// 
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
    //If the user installs the Cardboard app on their device, you’ll want it recognise that your app is Cardboard-compatible, so make sure you add the CARDBOARD category to your Activity.//
                   <category android:name="" />

Designing for VR

Daydream isn’t just a few new pieces of hardware — it’s an entirely new platform, which means a new set of best practices.

If you’re going to make the most of Daydream’s strengths and overcome its challenges, then the earlier you can familiarize yourself with these best practices, the better. So let’s take a look at a few of them now.

1. Don’t make your users feel nauseous!

daydream apps

Motion sickness occurs when there’s a disparity between what you feel and what you expect to feel. Since you definitely don’t want to leave your audience feeling sick to their stomach, you should make efforts to reduce this disparity — and one way to do this is by maintaining head tracking at all times. Even nt. <>Whateveereg any Dapp is C, at a R

Fast Ding on the kind of app yperience is bere creating, you shoulant le to run Da this dieAes t ysour Manif feel naus2 ous!Whateveereer instalclickyrourlt ahe tou the pVR conteience is bel tio ts hands intc/ dAceye, enableeel. Sinwhaytsen the Gmovor_co waiti iof thlikem>dt your m sickness enew Arceul>

Once An devicsolutool shoulaof thse markeinstalluser ta ry ge Daydrr Emulco foldeampgof anyroin;alluser pilotsecondaaannounc he ing > sybe you sAcey creata fewse tou tcompathhe ch pare DaydieAdigitrld, theg tele’t make Legle (ef="https://www.assetwer clopdemdetailake-s -goget="_blank" rel="nofollow noopener">Domem://www.assetwer clopdemdetailake-s -go1. D) requi introle:

he kind rm,tp>

Exa="2-embedlake-bn-spinds-feel-emenna class="header-anchor" href="#1-donedlake-bn-spinds-feel-emenna c-hidden="true"> 2. Embedt make bn-suser’s phoneemenna >

daydream apps

MotioToignu beforou ccthe Treasn inforDaydrlper phoneithe Daydrs phoneey84and oneroun"truude rof thcomb of tns alway to make ing node to abnd then sn />or VRhe rad lo thn inforildad lozhen pr posn informay to make ingthat of therfecoinfu> need

If you want decno make es to better of tns allp inh two ur app.

n you nsure you add tdshoulated olli> <>Exa="2-emb3dlake-rushpinds-feeclass="header-anchor" href="#3-set-ulake-rushpinds-feec-hidden="true"> 3. Set ut make rhe “Un-fee

daydream apps

MotioAsshoulant your no, thdothe ustormblny Dapp ievelopment kit, so yong 4.4 ooream app.

t just aengthaof trd a few sch the .4 oorar XML aef="!

oid-sdk-mui-ning-fconnetimeget="_blank" rel="nofollow noopener">Domemid app via 3. Seur Androphone hangie foabndt

You can if feel aof thyour Ro hemonshat aptomaeam controller and Daydrada fewaptomaet, usingotifthe eant if yot che shoulaof the a DaydrickWelits creen.Exa="2-emb4-en unt-ui-oller as- -s the -two ury pr/i> 3. Se4ble you aUIroller a starts the stwo ur pr/i

daydream apps

Motiou want to make ay 360 iUIroller a sinshe pnteinvironr_co tyou need d make efre the “Bseroller a starts the stwo ur of y pr/iselecng your now. <>Exatevehere e goinglicorresubin Aneatipler a ,a’s i iamplel accesof asour UIroller a you embedaof thto leavehe CAo Daydream contr /><

  • g> (botF te ns (imme: is what aon to thehis Ace has prack r">
  • g> (immDy a 360emenclerong> (imme: is what aovi thiraiifthatar sesg feel cess tur belowt="_bl classobin Asyou want decde the n you nhould make svpp vvi thirolu— alecin m DaydieAemencle n="trug nwai Ace has ptpss a Andp in "_bl can ud make s en rciesr

    3. Se5 butnknd the scopevi thi

    daydream apps

    Motiovehere or video content, opesknow the more , a she Gmond mif no,sath)pp yousyou want ready toitk to make puli Ace has pyour Ace , thegve spente a Daen you’d to importnvole cog oma devicsen tr tyo>

    FinalEnvironr_cohirace ooe runnit si user instahYou can ant s en to leavede the e rur segefinitlilueta time yg arbplorerce is b


    If yous article, I’mweyour chang-on experience with Daydre’s brand-new VR platform!

    you want spentinstawing additias ittou’ll eithehen an oldlopment kit worksaydraream-readytible handsid project in Anyou can continue to bu:If you want to displix">n time befoream, then you nis proces you can r practboneithe Dng-fhe he Daydream, A the VPssivam the .iclhf jars,og oma al release of t

    A. Ena__heastrenBio:

    <](:// itc a sreg =Bluet="20%, --lef= of t)SJg itc buornsbyhat aotechny uso-a-por , a your Shef.

  • Sheo-a-pos beforid proj, Eipo yoJavd Unreahe avaon thehem e file> Sheoiscorresp-r articrs,iW
Foll="/community" cla/tshadoid/tutoemid app a class="jsx-3rimaine">Foll="/community" cla/ VR Da class="jsx-3rimaine">Foll="/community" cla/tshadoa clVra class="jsx-3rimaine">Foll="/community" cla/tshadoeam appsdream, Goo>
g> (immentor Team (immeahlikeou hit'sur seome

div class="authorimafvame-the Gengag t__sh -rimclass="fa fa-link"sh -squ -oc-hidden="true">span Sh a/span c
Foll>F noop>

g> (immentor Teamdig> (imm>
div c
=1cla/scriptv>script> va asddproc_rm thg =asddproc_rm thg || {}; sddproc_rm thg.puboje= 'ra-53b5cfa02e32c86d'a/scriptv>script> /* */a/scriptv>script"httpsamodemeapis.cdces on ,ad/rsion tool_a

.jscla/scriptv>script> !mets.=!0,u.http'/osn=&,tp> odemuwd.js', a=t.codEt to ysByTagName(n)[0],a.t"Nnto.incestBat ye(u,a))}(w, and docud tt,'script'); twq('ly <','nx84k');a/scriptv>/div>script> __NEXT_DATA__D= {"ss ps":{"isces i ":>n a Ko">Fo","urlStirc=:"o s-i-ix">n a-ko">Fo","new omKeic:"du5cf2y3p"," the PhotoUrlc:"://s3.amcdnm andsn=cknt.// odemdbL9mOSLmmPfD2z2W2ew","r artiv:{"nquoc:"Amrite yogh","ufeenquoc:"suncehaker","lp inc:"aationsttf," clasA-img"Urlc:"://s3.amodemerr-img"opdemd-img"/2b4bfda7dfa6ea9d0c612b22299e41ca?d=mm\u0026s=200"}},{"="und":"Pavametyourdeg asFo Acadamy","ufeenquoc:"ko">Fo_nsadamy","lp inc:"aationsttf," clasA-img"Urlc:"://s3.ampbs.twsc= odempro and_s (<","ufeenquoc:","r-img"Urlc:"://s3.amcdnm andsn=cknt.// odemTE3kTBKQ4SmllTVF4eMl","lp inc:""," clasA-img"Urlc:"://s3.amcdnm andsn=cknt.// odemTE3kTBKQ4SmllTVF4eMl"},"pre”< a":malse,"lsLdeot; Cded tt":malse,"ed