Mobile Development Documentation

Similar documents
Oculus Mobile Software Development Kit (SDK) Device and Environment Setup Guide

Mobile Development Documentation

Getting Started with Android Development

Tutorial on Basic Android Setup

Setting up Sudoku example on Android Studio

Installing the Android SDK

Intel Integrated Native Developer Experience (INDE): IDE Integration for Android*

Android Environment SDK

Introduction to Gear VR Development in Unity APPENDIX A: SETUP (WINDOWS 7/8)

Android Setup Phase 2

Download and Installation Instructions. Android SDK and Android Development Tools (ADT)

Introduction to Gear VR Development in Unity APPENDIX A: SETUP (MAC OS X)

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

ADT Plugin for Eclipse

Home Course Catalog Schedule Pricing & Savings Training Options Resources About Us

Building graphic-rich and better performing native applications. Pro. Android C++ with the NDK. Onur Cinar

Application Development Setup Guide

Android Development. 吳 俊 興 國 立 高 雄 大 學 資 訊 工 程 學 系

WA1826 Designing Cloud Computing Solutions. Classroom Setup Guide. Web Age Solutions Inc. Copyright Web Age Solutions Inc. 1

Android Environment SDK

Getting Started using the SQuirreL SQL Client

CSA Software Listing Table of Contents. Both Windows and Mac platforms are supported.

Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.

IBM TRIRIGA Anywhere Version 10 Release 4. Installing a development environment

1) SETUP ANDROID STUDIO

Developing In Eclipse, with ADT

With a single download, the ADT Bundle includes everything you need to begin developing apps:

Introduction to Android Development

Oracle FLEXCUBE Direct Banking Android Tab Client Installation Guide Release

Using Microsoft Visual Studio API Reference

Android Development Tutorial. Nikhil Yadav CSE40816/ Pervasive Health Fall 2011

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02

Download and Installation Instructions. Android SDK and Android Development Tools (ADT) Microsoft Windows

Android 4.4 App Development Essentials

Silk Test Testing Mobile Web Applications

Lab 0 (Setting up your Development Environment) Week 1

XenMobile Logs Collection Guide

VMware Horizon FLEX User Guide

Fahim Uddin 1. Java SDK

Download and Installation Instructions. Android SDK and Android Development Tools (ADT) Microsoft Windows

1. Product Information

Board also Supports MicroBridge

Setting Up Your Android Development Environment. For Mac OS X (10.6.8) v1.0. By GoNorthWest. 3 April 2012

Hello World. by Elliot Khazon

SAP Web IDE Hybrid App Toolkit Add-on

Hudson configuration manual

How to Install Applications (APK Files) on Your Android Phone

System Reference 2013

Android Programming: Installation, Setup, and Getting Started

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Online Backup Client User Manual Linux

Practice Fusion API Client Installation Guide for Windows

UP L18 Enhanced MDM and Updated Protection Hands-On Lab

Kaspersky Password Manager

Guide to Installing BBL Crystal MIND on Windows 7

Android Development Tools for Eclipse

Running a Program on an AVD

VMware Horizon FLEX User Guide

VMware Horizon FLEX User Guide

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

App Preparation and Submission Guide

Introduction: The Xcode templates are not available in Cordova or above, so we'll use the previous version, for this recipe.

Developing for MSI Android Devices

RecoveryVault Express Client User Manual

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3

Android: How To. Thanks. Aman Nijhawan

Example Connection between USB Host and Android

Android: Setup Hello, World: Android Edition. due by noon ET on Wed 2/22. Ingredients.

Published: SWD

Online Backup Linux Client User Manual

Homework 9 Android App for Weather Forecast

Online Backup Client User Manual

TIBCO ActiveMatrix BusinessWorks Plug-in for TIBCO Managed File Transfer Software Installation

Intel Unite Solution. Standalone User Guide

How to Set Up Your PC for Android Application Development


Silk Test Testing Mobile Applications

Python for Series 60 Platform


Epidefender Studio Installation notice

JAMF Software Server Installation Guide for Windows. Version 8.6

Install guide for Websphere 7.0

A Practical Guide to creating, compiling and signing an Android Application using Processing for Android.

Compiere ERP & CRM Installation Instructions Windows System - EnterpriseDB

Waspmote IDE. User Guide

Android Development Setup [Revision Date: 02/16/11]

InventoryControl for use with QuoteWerks Quick Start Guide

Tutorial: BlackBerry Object API Application Development. Sybase Unwired Platform 2.2 SP04

Tutorial: Android Object API Application Development. Sybase Unwired Platform 2.2 SP02

Kaspersky Lab Mobile Device Management Deployment Guide

DameWare Server. Administrator Guide

Migrating MSDE to Microsoft SQL 2008 R2 Express

POOSL IDE Installation Manual

Zanibal Plug-in For Microsoft Outlook Installation & User Guide Version 1.1

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

Title: Appium Automation for Mac OS X. Created By: Prithivirajan M. Abstract. Introduction

How To Install An Aneka Cloud On A Windows 7 Computer (For Free)

Quick Start Guide 0514US

How to Set Up Your PC for Android Application Development

Transcription:

Mobile Development Documentation Version 1.0.0

2 Introduction Mobile Copyrights and Trademarks 2015 Oculus VR, LLC. All Rights Reserved. OCULUS VR, OCULUS, and RIFT are trademarks of Oculus VR, LLC. (C) Oculus VR, LLC. All rights reserved. BLUETOOTH is a registered trademark of Bluetooth SIG, Inc. All other trademarks are the property of their respective owners. Certain materials included in this publication are reprinted with the permission of the copyright holder. 2

Mobile Contents 3 Contents Introduction to the Mobile SDK... 5 Getting Started... 5 System and Hardware Requirements... 5 Application Signing...7 SDK Contents... 7 Mobile SDK Setup Guide... 10 Device Setup...10 Setting up your System to Detect your Android Device...10 Configuring your Android Device for Debugging... 11 Android Studio Development Environment Setup (Beta)... 12 Android Studio Development Software Setup for Windows... 13 Android Studio Development Software Setup for Mac OS X... 15 Android Studio Basics... 17 Native Debugging with Android Studio... 22 Native Debugging with ndk-gdb... 24 Android Development Environment Setup for Eclipse... 27 Android Eclipse Development Software Setup for Windows... 27 Android Eclipse Development Software Setup for OS X... 32 Mobile VR Application Development... 38 Introduction to Mobile VR Design... 38 Performance Advice for Early Titles...38 Frame Rate... 39 Scenes...39 Resolution... 40 Hardware Details...40 Universal Menu... 41 Reserved User Interactions...41 Implementation Overview... 42 Runtime Threads... 42 Power Management...43 Fixed Clock Level API... 43 Power Management and Performance... 43 Power State Notification and Mitigation Strategy... 44 Front Buffer Rendering... 45 TimeWarp...46 TimeWarp Minimum Vsyncs... 46 Consequences of not rendering at 60 FPS... 47 TimeWarp Debug Graph...48 User Interface Guidelines... 48 In a Word: Stereoscopic!... 48 The Infinity Problem... 49 Depth In-Depth... 49 Gazing Into Virtual Reality...50 Media and Assets... 51 Mobile VR Media Overview... 51 Panoramic Stills...51

4 Contents Mobile Panoramic Videos... 51 Media Locations... 52 Movies on Screens... 52 Native VR Media Applications...54 Oculus Cinema Theater Creation...56 Detailed Instructions...56 Theater Design Principles... 62 FBX Converter...63 Overview... 63 Command-Line Interface... 66 Optimization... 68 Native Development Guide...70 Native Source Code... 70 Overview... 70 Native User Interface...71 Input Handling...71 Creating New Native Applications...72 Template Project Using the Application Framework... 72 Integration with Third-Party Engines...73 Android Manifest Settings...73 Native Samples... 74 Native SoundEffectContext... 75 Mobile Native SDK Migration... 76 Migrating to Mobile SDK 1.0.0...76 Migrating to Mobile SDK 0.6.2.0...79 Migrating to Mobile SDK 0.6.1.0...81 Migrating to Mobile SDK 0.6.0...83 Testing and Troubleshooting...90 Oculus Testing Tools and Procedures... 90 Developer Mode: Running Apps Outside of the Gear VR Headset...90 VrCapture and Oculus Remote Monitor... 90 Local Preferences... 105 Android Debugging...106 Adb... 106 Logcat... 108 Application Performance Analysis... 109 Basic Performance Stats through Logcat...109 SysTrace... 110 NDK Profiler...111 Rendering Performance: Tracer for OpenGL ES... 112 Release Notes... 115 1.0 0.6 0.5 0.4 Release Release Release Release Notes...115 Notes...116 Notes...122 Notes...126

Mobile Introduction to the Mobile SDK 5 Introduction to the Mobile SDK Welcome to mobile application development for Gear VR! This guide provides an overview of the SDK contents and details the requirements for development. Getting Started Ready to start developing? The Mobile SDK Setup Guide is a one-time guide to preparing and configuring your development environment. We have compiled recommendations for developing, debugging, and analyzing VR applications that we recommend to all developers: Mobile VR Application Development Guide Android Debugging Performance Analysis Unity and Unreal Developers For setup instructions, be sure to review the Mobile Setup for Unity and Unreal Developers section of the Mobile SDK Setup Guide. Unity developers should then focus on our Utilities for Unity documentation (Unity 5.1+) or Unity Legacy Integration documentation (Unity 4.6+), available on our documentation site: https:// developer.oculus.com/documentation/ Native Developers Once you have completed the setup process described by the Setup Guide, focus on the Native Development Guide. Application Submission For information on preparing to submit your mobile VR application to Oculus for distribution through the Oculus Store, see our Publishing Guide. Thank you for joining us at the forefront of virtual reality! Questions? Visit our developer support forums at https://developer.oculus.com. Our Support Center can be accessed at https://support.oculus.com/. System and Hardware Requirements Please begin by making sure that you are using supported hardware and devices for this release of the Oculus Mobile SDK.

6 Introduction to the Mobile SDK Mobile Operating System Requirements The Oculus Mobile SDK currently supports the following operating systems: Windows 7 or 8 Mac OS: 10.6+ (x86 only) Minimum System Requirements The following computer system requirements for the Oculus Mobile SDK are based on the Android SDK system requirements: 2.0+ GHz processor 2 GB system RAM Supported VR Headsets Samsung Gear VR Supported Devices Samsung Note 4 Samsung Note 5 Samsung Galaxy S6 Samsung Galaxy S6 Edge Samsung Galaxy S6 Edge+ Target Device Requirements API Level 19 (Android 4.4.2) or later Accessories Bluetooth Gamepad We recommend using a compatible Bluetooth gamepad for development, such as the SteelSeries Free or Moga Pro. A gamepad is necessary for testing the sample applications which come with this release. Compatible gamepads must have the following features: Wireless Bluetooth connection (BT3.0) Compatible with Android devices Start and Select buttons Typical controls include: One Analog Stick Action Button (4) Trigger Button (2) Bluetooth Keyboard (optional) It is useful (but not required) to have a Bluetooth keyboard during development. The Logitech K810 is known to function well.

Mobile Introduction to the Mobile SDK 7 Application Signing Oculus mobile apps require two distinct signatures at different stages of development. Oculus Signature File (required during development, remove for submission) Android Application Signature (required for submission) Oculus Signature File (osig) During development, your application must be signed with an Oculus-issued Oculus Signature File, or osig. This signature comes in the form of a file that you include in your application in order to access protected lowlevel VR functionality on your mobile device. Each signature file is tied to a specific device, so you will need to generate osig files for each device that you use for development. When your application is submitted and approved, Oculus will modify the APK so that it can be used on all devices. Please see our osig self-service portal for more information and instructions on how to request an osig for development: https://developer.oculus.com/tools/osig/ Android Application Signing Android uses a digital certificate (also called a keystore) to cryptographically validate the identity of application authors. All Android applications must be digitally signed with such a certificate in order to be installed and run on an Android device. All developers must create their own unique digital signature and sign their applications before submitting them to Oculus for approval. For more information and instructions, please see Android's "Signing your Applications" documentation: http://developer.android.com/tools/publishing/app-signing.html Make sure to save the certificate file you use to sign your application. Every subsequent update to your application must be signed with the same certificate file, or it will fail. Note: Your application must be signed by an Android certificate before you submit it. Android Application Signing and Unity Unity automatically signs Android applications with a temporary debug certificate by default. Before building your final release build, create a new Android keystore and assign it with the Use Existing Keystore option, found in Edit > Project Settings > Player > Publishing Options. For more information, see the Android section of Unity's documentation here: http://docs.unity3d.com/manual/class-playersettings.html. SDK Contents Included with this SDK, you will find the following: Native framework for building high-performance VR Applications. Example native and Unity Projects with source to provide a model for creating your own VR applications. Pre-built sample applications, some implemented in native and some in Unity. Tools to assist with native development.

8 Introduction to the Mobile SDK Mobile Unity Resources The Oculus Utilities for Unity and Legacy Integration packages are available for download separately at our downloads page here: https://developer.oculus.com/downloads. The Unity samples included with the Mobile SDK are compatible with the Oculus Legacy Integration package only, for use with Unity 4. If you are using Unity s first-party VR support in Unity 5.1 or later, you will find samples compatible with our Utilities package available for download, also at our downloads page. For more information on the Oculus Mobile SDK Example contents, please see our Unity documentation. Sample Applications and Media Note: The sample applications included with the SDK are provided as a convenience for development purposes. Some of these apps are similar to apps available for download from the Oculus Store. Due to the potential for conflict with these versions, we do not recommend running these sample apps on the same device on which you have installed your retail Gear VR Innovator experience. If you are using the Samsung Note 4, please take care to secure the retail media content bundled with the SM-R320. It will be difficult if not impossible to replace. Table 1: Sample Native Applications Application Description A viewer for panoramic stills. Oculus 360 Photos A viewer for panoramic videos. Oculus 360 Videos Plays 2D and 3D movies in a virtual movie theatre. Oculus Cinema A sample scene of colorful cubes.

Mobile Introduction to the Mobile SDK 9 Application Description VR Cube World Table 2: Sample Unity Applications Application Description A simple game example in which blocks can be thrown to knock over structures and collect stars. (source and APK, currently Unity 4 only) BlockSplosion An example app that renders a scene and character from Shadowgun by Madfinger Games. (APK) Shadowgun, by Madfinger Games For the Mobile SDK, we have limited pre-loaded media. Please add your own media by consulting the following table and media creation guidelines for compatibility: Table 3: Sample Media Application Path for Media on the SD Card Oculus Cinema - 2D Movie Movies\ DCIM\ Oculus\Movies\My Videos Oculus Cinema - 3D Movie Movies\3D\ DCIM\3D\ Oculus\Movies\My Videos\3D\ Oculus 360 Video - 360-degree panoramic video Oculus\360Videos\ Oculus 360 Photo - 360-degree static photos Oculus\360Photos\ Note: Non-360 degree photos will not render properly. For more information on media management, see Mobile Media VR Overview.

10 Mobile SDK Setup Guide Mobile Mobile SDK Setup Guide This guide will walk you through setting up your Samsung device and preparing your environment for mobile VR application development. Installing the Oculus Mobile SDK Download the Mobile SDK here: https://developer.oculus.com/downloads/. The Mobile SDK is composed of a compressed archive in.zip format, which contains both source and media files: ovr_sdk_mobile_<version>.zip. Once downloaded, extract the.zip file into a directory of your choice (e.g., C:\Oculus\Mobile). Mobile Setup for Unity and Unreal Developers Most Unity and Unreal developers do not need to install Android Studio or NDK for development. Developers using a third-party game engine should follow the instructions in our Device Setup guide, and install the Java Development Kit (JDK) and Android SDK before beginning development. Note: You must download the Oculus Mobile SDK if you wish to use OVRMonitor. Unity developers: see Unity s Getting Started with Android Development for more information. Unreal developers: see Unreal s Android Quick Start for more information. Device Setup This section will provide information on how to set up your supported device and gamepad for running, debugging, and testing your Gear VR application. Please review the System and Hardware Requirements above for the list of supported devices for this SDK release. Note: This information is accurate at the time of publication. Unfortunately, we cannot guarantee the consistency or reliability of third-party applications discussed in these pages, nor can we offer support for any of the third-party applications we describe. Setting up your System to Detect your Android Device You must set up your system to detect your Android device over USB in order to run, debug, and test your application on an Android device. If the device is not automatically detected by your system when connected over USB, you may need to manually update the drivers. More information can be found in the Using Hardware Devices section at http:// developer.android.com/tools/device.html. Windows If you are developing on Windows, you need to install a USB driver for adb. For an installation guide and links to OEM drivers, see the Android OEM USB Drivers document.

Mobile Mobile SDK Setup Guide 11 Samsung Android drivers may be found on their developer site: http://developer.samsung.com/android/toolssdks/samsung-android-usb-driver-for-windows Windows may automatically detect the correct device and install the appropriate driver when you connect your device to a USB port on your computer. However, if Windows is unable to detect your device, you may still need to update the drivers through the Windows Device Manager, even if your device was automatically detected. Access the Device Manager through the Windows Control Panel. If the device was automatically detected, it will show up under Portable Devices in the Device Manager. Otherwise, look under Other Devices in the Device Manager and select the device to manually update the driver. To verify that the driver successfully recognized the device, open a command prompt and type the command: adb devices Note: You will need to successfully setup your Android development environment in order to use this command. For more information, see the next section: Android Development Environment Setup If the device does not show up, verify that the device is turned on with enough battery power, and that the driver is installed properly. Mac OS If you are developing on Mac OS X, you do not need to install USB drivers. Your Samsung device may display a notification recommending you install Android File Transfer, a handy application for transferring files between OS X and Android. Configuring your Android Device for Debugging In order to test and debug applications on your Android device, you will need to enable specific developer options on the device. Developer Options Developer options may be found under: Home -> All Apps -> Settings -> System -> Developer options. Developer options may be hidden by default. If so, you can expose these options with the following steps: 1. Go to Home -> All Apps -> Settings -> System -> About device. 2. Scroll down to Build number. 3. Press Build number seven times. You should be informed that Developer options has been enabled. Once you have found Developer options, enable the following: USB Debugging: This will allow the tools to install and launch deployed apps over USB. You should see the screen shown on the accompanying figure.

12 Mobile SDK Setup Guide Mobile Note: If the above screen does not appear, ensure that your system recognizes the device and toggle USB Debugging off then back on. Check Always allow this computer and hit OK. To purge the authorized whitelist for USB Debugging, press Revoke USB debugging authorizations from the Developer options menu and press OK. Allow mock locations: This will allow you to send mock location information to the device (convenient for apps which use Location Based Services). Verify apps via USB: This will check installed apps from ADB/ADT for harmful behavior. Display Options The following display options are found in: Home -> Apps -> Settings -> Sound and Display. Lock screen/screen Security/Screen lock: Set to None to make the Home screen is instantly available, without swipe or password. Useful to quickly get in and out of the phone. Display/Screen timeout: Set the time to your desired duration. Useful if you are not actively accessing the device but wish to keep the screen awake longer than the default 30 seconds. See Android Debugging for more information. Android Studio Development Environment Setup (Beta) This section describes setup and configuration of the Android Studio IDE and Gradle for building native Oculus Android mobile applications. Android has deprecated support for Eclipse, ADT, and Ant, and now specifies Android Studio and Gradle as its core development tools. Oculus Mobile SDK 1.0 introduces our beta integration with Android Studio and Gradle, and we no longer ship Eclipse project files for our SDK samples or libs. Oculus support for Android Studio is in beta, as the IDE is under development and key components are not complete (e.g., NDK integration is currently offered with Preview Support only). We are retaining our legacy Eclipse instructions for now, but recommend that you begin planning migration to Android Studio or to your preferred IDE, as Android has announced their intention to terminate Eclipse support. For developers who are just beginning, we recommend starting with Android Studio.

Mobile Mobile SDK Setup Guide 13 For information on migrating to Android Studio from previous installations, see Migrating Eclipse Projects to Android Studio in Android Studio Setup and Basics. If you have problems installing or using Studio, please let us know on the Oculus Forums. Android Studio Development Software Setup for Windows In order to develop Android applications, you must have the following software installed on your system: 1. Java Development Kit (JDK) 2. Android Studio Development Bundle or Standalone Android SDK Tools 3. Android Native Development Kit (NDK) Gradle installation is recommended but not required. See Gradle for more information. Java Development Kit (JDK) The Java Development Kit is a prerequisite for Android Studio and Gradle. The latest version which has been tested with this release is JDK 8u45, available from the Java Archive Downloads page: http://www.oracle.com/technetwork/java/javase/downloads/java-archivejavase8-2177648.html The latest JDK version is available here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8downloads-2133151.html Once downloaded and installed, add the environment variable JAVA_HOME and set its value to the JDK install location. For example, the value may be C:\Program Files\Java\jdk1.8.0_45, if you have installed the x64 version. Based on the default installation path of Java SE 8u45, the correct syntax when using set from the command line is: set C:\Program Files\Java\jdk1.8.0_45 The JAVA_HOME value must not include quotation marks; must not use quotes with the set command, even though the path has a space in it; and must be your actual path, which may differ from these examples. Additionally, add the JDK to the value of your PATH, e.g. C:\Program Files\Java\jdk1.8.0_45\bin Android Studio Installation Download the Android Studio Bundle from the following location: https://developer.android.com/sdk/ index.html The Android Studio Development Bundle includes the basic tools you need to begin developing Java Android Applications: Android Studio IDE Android SDK tools Latest Android Platform Latest System Image for Emulator

14 Mobile SDK Setup Guide Mobile Once downloaded, follow Android s installation instructions: https://developer.android.com/sdk/installing/ index.html?pkg=studio Installing Additional Packages and Tools You must download additional packages required by the Mobile SDK via the Android Studio SDK Manager, found in Tools > Android > SDK Manager. Android Studio may prompt you to take this step automatically the first time you launch it. The following packages are required for native development: Android SDK 4.42. API level 19 or later Android Build Tools 22.0.1 The following optional packages under the SDK Tools tab in the SDK Manager are known to work with the Mobile SDK: Android SDK Tools 23.0.2 Android SDK Platform-tools 20 Android SDK Build-tools 20 More information about installing additional packages is found here: https://developer.android.com/sdk/ installing/adding-packages.html Android Native Development Kit (NDK) The Android Native Development Kit (NDK) is a toolset that allows you to implement parts of your app using native code languages such as C and C++. It is used extensively by the sample applications included with this release. Note: You may install the NDK during the Android Studio installation process, but we recommend installing it manually to be sure that your command-line environment is set up properly and agrees with your Studio setup. The last version of the NDK known to work with the Mobile SDK is r10e. 1. Download the appropriate version of NDK from the following location: https://developer.android.com/ndk/ downloads/index.html. 2. Save the exe to the directory where you would like to install it, e.g., C:\Dev\Android\android-ndk-r10e\. 3. Once downloaded, double-click the exe to unpack its contents into the parent directory. 4. Add the NDK location to your PATH. For example: C:\Dev\Android\android-ndk-r10e\ 5. Add the environment variable ANDROID_NDK, and set the value to your Android NDK location. For example: C:\Dev\Android\android-ndk-r10e 6. Using the above location as an example, the correct syntax for setting your environment variable using set from the command line is: set ANDROID_NDK=C:\Dev\Android\android-ndk-r10e Gradle Gradle is a build automation suite used by our standalone build scripts and by Android Studio to manage dependencies and allow for custom build logic. Gradle replaces the previous Android build system, Ant, which is now deprecated for use in Android development. It is not necessary to install Gradle to use the Mobile SDK. Oculus Mobile SDK 1.0+ build scripts use the Gradle Wrapper (gradlew), a small wrapper that automatically downloads and installs Gradle the first time you build a project. However, if you wish to install the full version of Gradle, we have included instructions.

Mobile Mobile SDK Setup Guide 15 The latest version which has been tested with this release is Gradle 2.7. Choose the Complete download if you want the Gradle source and offline documentation. To install Gradle: 1. 2. 3. 4. 5. Download version 2.7 from http://gradle.org/gradle-download/ Extract into the desired development directory, e.g., C:\Dev\Android\gradle-2.7. Add the Gradle bin directory to your PATH variable, e.g.: C:\Dev\Android\gradle-2.7\bin Restart your terminal window to fetch the updated PATH variable. You should now be able to build with: build -g Android Studio Development Software Setup for Mac OS X In order to develop Android applications, you must have the following software installed on your system: 1. 2. 3. 4. Xcode Java Development Kit (JDK) Android Studio Android Native Development Kit (NDK) Gradle installation is recommended but not required. See Gradle for more information. Xcode Before installing any Android development tools, you must install Xcode. Once installation is complete, some of the following steps (such as installing the JDK) may be unnecessary. To download Xcode, visit https://developer.apple.com/xcode/download/ Java Development Kit (JDK) Install the JDK if it is not already present on your system. If you have already installed Xcode, this step may be unnecessary. The latest version tested with this release is JDK 8u45 - it may be downloaded at the following location: http:// www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Android Studio Download the Android Studio Bundle from the following location: https://developer.android.com/sdk/ index.html The Android Studio Development Bundle includes the basic tools you need to begin developing Java Android Applications: Android Studio IDE Android SDK tools Latest Android Platform Latest System Image for Emulator Once downloaded, follow the install instructions located here: https://developer.android.com/sdk/installing/ index.html?pkg=studio

16 Mobile SDK Setup Guide Mobile Installing Additional Packages and Tools You must download additional packages required by the Mobile SDK via the Android Studio SDK Manager, found in Tools > Android > SDK Manager. Android Studio may prompt you to take this step automatically the first time you launch it. The following packages are required for native development: Android SDK 4.42. API level 19 or later Android Build Tools 22.0.1 The following optional packages under the SDK Tools tab in the SDK Manager are known to work with the Mobile SDK: Android SDK Tools 23.0.2 Android SDK Platform-tools 20 Android SDK Build-tools 20 More information about installing additional packages is found here: https://developer.android.com/sdk/ installing/adding-packages.html Android Native Development Kit (NDK) The Android Native Development Kit (NDK) is a toolset that allows you to implement parts of your app using native code languages such as C and C++. It is used extensively by the sample applications which come with this release. The latest version which has been tested with this release is NDK r10e - it is available for download at the following location: https://developer.android.com/tools/sdk/ndk/index.html. Once downloaded, extract the NDK to your home/dev folder (~/dev). Your dev folder should look something like the following: Note that Android Studio and the NDK are extracted into their own folders. These folders may be given any name you wish, but they must be installed into separate folders to avoid any conflict between the two packages. You can read more about installation and use of the NDK here: http://developer.android.com/tools/sdk/ndk/ index.html#installing.

Mobile Mobile SDK Setup Guide 17 Gradle Gradle is a build automation suite used by our standalone build scripts and by Android Studio to manage dependencies and allow for custom build logic. Gradle replaces the previous Android build system, Ant, which is now deprecated for use in Android development. It is not necessary to install Gradle to use the Mobile SDK. Oculus Mobile SDK 1.0+ build scripts use the Gradle Wrapper (gradlew), a small wrapper that automatically downloads and installs Gradle the first time you build a project. However, if you wish to install the full version of Gradle, we have included instructions. The latest version which has been tested with this release is Gradle 2.7. Choose the Complete download if you want the Gradle source and offline documentation. Manual Installation 1. 2. 3. 4. Download from http://gradle.org/gradle-download/ (requires version 2.5+) Extract into some common development directory. For example: ~/android/gradle-2.7 Add the Gradle bin directory to your PATH variable. For example: ~/android/gradle-2.7/bin Open a new Terminal window to refresh the PATH variable. You should now be able to build with:./build.py -g Install using Brew: Requires Brew, an optional package manager for OS X. 1. Run sudo brew install gradle in the terminal. 2. Open a new terminal window to refresh the PATH variable. You should now be able to build with:./build.py -g Install using MacPorts: Requires MacPorts, an optional package manager for OS X. 1. Run sudo port install gradle in the terminal. 2. Open a new terminal window to refresh the PATH variable. You should now be able to build with:./build.py -g Android Studio Basics This guide provides basic recommendations for working with the Oculus Mobile SDK in Android Studio and Gradle, and is intended to supplement the relevant Android Studio documentation. Migrating Eclipse Projects to Android Studio For a general discussion of how to import existing Eclipse projects into Android Studio, please see the instructions provided by Android here: http://developer.android.com/sdk/installing/migrate.html Getting Started with Oculus Native Samples: Import Gradle Project When you first launch Android Studio after initial setup, you will be presented with a Welcome screen. Select Import project and point it at our root Gradle project.

18 Mobile SDK Setup Guide Mobile For convenience we have set up the root Android Studio project to include all of our samples which provides for a quick way to get started with our SDK. You may also import any build.gradle project in any of the Mobile SDK VrSamples directories, and Android Studio will automatically import the required dependencies without bringing in all of the samples.

Mobile Mobile SDK Setup Guide 19 Project Overview We recommend changing the Project Overview from the default Android to Project, which provides a good overview of the entire directory structure, with imported project directories shown in bold.

20 Mobile SDK Setup Guide Mobile Project Settings After importing your project, verify that the SDK and NDK locations are configured properly in File > Project Structure..., or your build will fail.

Mobile Mobile SDK Setup Guide 21 Select Target Configuration, Build, and Run You may build and run your application on your device directly from Android Studio. This will compile your project, build the APK, copy it to the phone via USB/Wi-Fi, and prepare it for launching. If your phone is set to Developer Mode (see Developer Mode for instructions), your application will play without being inserted into your Gear VR headset. Otherwise, when the process completes you will be prompted to insert your mobile device into the headset to launch the application. Make sure you have followed the configuration steps in the Mobile SDK Setup Guide to ensure your device is configured appropriately. Applications must be signed with an Oculus Signature File (osig) in order to run (see Application Signing for more information). Select the target configuration you wish to build before building by selecting Edit Configurations in the project dropdown menu in the Android Studio toolbar. Immediately to the left of the project dropdown, you will see Run and Debug icons. Click on either icon to build and run your project. After clicking on Run or Debug, the Choose Device dialog window will open. This is usually set to an emulator by default. Select Choose a running device and select the appropriate option. You may also build and clean your project without running it by using the Build menu.

22 Mobile SDK Setup Guide Mobile Syncing Projects If you edit a *.gradle file or install an update to the Oculus Mobile SDK which includes updated Gradle Projects, you must Gradle Sync to update the Android Studio project files. Click on Sync Project with Gradle Files in the Android Studio toolbar as shown. Native Debugging with Android Studio This section introduces debugging our sample native apps in Android Studio. Note: Native support in Android Studio is still under development. Some developers have reported problems using run-as with the Note 4 with Lollipop (5.0.x) and S6 with 5.0.0, which may cause issues with debugging. If you have problems debugging, try updating to the latest system software, and please let us know on the Oculus Forums. The default configurations created during project import only support Java debugging. Select Edit Configurations in the Configurations drop-down menu in the Android Studio toolbar. Create a new Android Native configuration as show below:

Mobile Mobile SDK Setup Guide 23 In the General tab of the Run/Debug Configuration dialog box, assign your configuration a name, select the target module, and select the target device mode: In the Native tab of the Run/Debug Configuration dialog box, add symbol paths:

24 Mobile SDK Setup Guide Mobile Note that ndk-build places stripped libraries inside the libs/ directory. You must point the symbol search paths at the obj/local/<arch> directory. This is also not a recursive search path, so you must put the full path to the obj/local/armeabi-v7a directory. Native Debugging with ndk-gdb This guide provides basic recommendations for using ndk-gdb to debug native mobile VR projects, and is intended to supplement the relevant Android Studio documentation.

Mobile Mobile SDK Setup Guide 25 The Android NDK includes a powerful debugging tool called ndk-gdb, a small shell script wrapped around GDB. Using ndk-gdb from the command line adds convenient features to your debugging workflow by allowing, for example, adding breakpoints, stepping through code, and inspecting variables. Create Breakpoints Break On Function (gdb) break SomeFunctionName() or (gdb) break SomeClass::SomeMethod() Example usage: (gdb) break OVR::VrCubeWorld::Frame(OVR::VrFrame const&) Breakpoint 2 at 0xf3f56118: file jni/../../../src/vrcubeworld_framework.cpp, line 292. Note: GDB supports tab completion for symbol names. Break On File:Line (gdb) break SomeFile.cpp:256 Conditional Breakpoints Add if <some condition> to the end of your break command. Example usage: (gdb) break OVR::VrCubeWorld::Frame(OVR::VrFrame const&) if vrframe.predicteddisplaytimeinseconds > 24250.0 Breakpoint 6 at 0xf3f58118: file jni/../../../src/vrcubeworld_framework.cpp, line 292. Break At Current Execution Example usage: (gdb) break OVR::VrCubeWorld::Frame(OVR::VrFrame const&) if vrframe.predicteddisplaytimeinseconds > 24250.0 Breakpoint 6 at 0xf3f58118: file jni/../../../src/vrcubeworld_framework.cpp, line 292. Break At Current Execution When an application is actively running, press control-c to break immediately and bring up the gdb prompt. Stepping Step Over (gdb) next or (gdb) n

26 Mobile SDK Setup Guide Mobile Step Into (gdb) step or (gdb) s Continue Execution (gdb) continue or (gdb) c Printing Print Struct You may enable pretty printing mode to add new lines between struct elements (optional): (gdb) set print pretty on To print the struct: (gdb) print SomeStructVariable Example usage: (gdb) print currentrotation $1 = { x = 23185.9961, y = 23185.9961, z = 0, static ZERO = { x = 0, y = 0, z = 0, static ZERO = <same as static member of an already seen type> } } printf Example usage: (gdb) printf "x = %f\n", currentrotation.x x = 23185.996094 Breakpoint Commands GDB breakpoints may be set to automatically execute arbitrary commands upon being hit. This feature is useful for inserting print statements into your code without recompiling or even modifying data at key points in your program without halting execution entirely. It is controlled by the commands command. You may specify the breakpoint number with an optional single argument; if omitted, the final breakpoint is used. You are then presented with a series of lines beginning with > where you may enter GDB commands (one per line) that will be executed upon hitting the breakpoint, until the command sequence is terminated with end.

Mobile Mobile SDK Setup Guide 27 In the following example, we create a breakpoint automatically prints the value of a local variable and then continues execution, upon being hit: (gdb) break OVR::VrCubeWorld::Frame(OVR::VrFrame const&) Breakpoint 1 at 0xf3f56118: file jni/../../../src/vrcubeworld_framework.cpp, line 292. (gdb) commands Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >silent >printf "time = %f\n", vrframe.predicteddisplaytimeinseconds >continue >end Text User Interface (TUI) To enable or disable the TUI, press CTRL+x followed by CTRL+a. For more information on TUI keyboard shortcuts, see https://sourceware.org/gdb/onlinedocs/gdb/tuikeys.html. Android Development Environment Setup for Eclipse This section describes setup and configuration of the Android Development Environment necessary for building Oculus Android mobile applications. Android Eclipse Development Software Setup for Windows Android Studio Android has deprecated support for Eclipse, ADT, and Ant, and now specifies Android Studio and Gradle as its core development tools. Oculus Mobile SDK 1.0 introduces our beta integration with Android Studio and Gradle, and we no longer ship Eclipse project files for our SDK samples or libs. For more information on Android Studio setup and use with the Oculus Mobile SDK, see Android Studio Development Environment Setup (Beta). Eclipse Development Requirements In order to develop Android applications, you must have the following software installed on your system: 1. 2. 3. 4. Java Development Kit (JDK) Android Development Tools (ADT) Bundle Android Native Development Kit (NDK) Apache Ant Java Development Kit (JDK) The Java Development Kit is a prerequisite for the Android Eclipse IDE (which comes with the ADT Bundle) as well as Apache Ant. The latest version which has been tested with this release is JDK 8u45. You may download the appropriate version for your OS from the following location: http://www.oracle.com/technetwork/java/javase/downloads/ jdk8-downloads-2133151.html

28 Mobile SDK Setup Guide Mobile Once downloaded and installed, add the environment variable JAVA_HOME, which should be set to the JDK install location. Depending on where it was installed, it may look like C:\Program Files\Java \jdk1.8.0_45, if you have installed the x64 version. Make sure your JAVA_HOME variable does not include quotation marks. Based on the default installation path of Java SE 8u45, the correct syntax when using set from the command line is: set JAVA_HOME=C:\Program Files (x86)\java\jdk1.8.0_45 Do not use quotes with the set command, even though the path has a space in it. Also, be sure to use your actual path, which may differ from these examples. Android Development Tools Bundle The Android Development Tools (ADT) Bundle includes everything needed to begin developing Java Android Apps: Android SDK Tools Android Platform Tools Latest Android Platform Eclipse with integrated ADT Plugin Latest System Image for Emulator For information on downloading and installing ADT, see http://developer.android.com/sdk/installing/installingadt.html. The ADT bundle comes in either a 32-bit or 64-bit version. This must match the JDK option you selected above. Installing Additional Packages and Tools The Android SDK does not include everything you will need for development by default. You must download additional packages via the SDK Manager before you begin. Note: Before launching the SDK Manager, make sure you have installed the JDK as outlined above. SDK Manager may fail to launch if it has not been installed. 1. Launch the Android SDK Manager located at: C:\Dev\Android\adt-bundle-<os_platform>\SDKManager.exe You may also launch it via Eclipse by selecting the SDK Manager in the toolbar. 2. Under the Tools section within Packages, select the following (if they are unselected): Android SDK Tools Rev. 23.0.5 Android SDK Platform-tools Rev. 21 Android SDK Build-tools Rev. 20 3. Our current Android build target is Android 4.4.2 (API 19). Select at least the following under the API 19 section: SDK Platform ARM EABI v7a System Image Sources for Android SDK (optional, but invaluable for dealing with the Android API) 4. Finally, under Extras at the bottom, select the following: Android Support Library Rev. 21.0.1

Mobile Mobile SDK Setup Guide 29 Google USB Driver Rev. 11 Figure 1: Android SDK Manager 5. Open Android 4.4.2 (API 19) and select the items for SDK Platform and ARM EABI v7a System Image. Note that Oculus Mobile SDK projects use API level 19.

30 Mobile SDK Setup Guide Mobile 6. Click Install X Packages, where X is the number of selected packages (it may vary based on what needs to be updated). 7. On the next dialog, choose Accept License. 8. Click Install to install and update packages. You may install additional packages above API 19 if you wish. Android SDK Tools 23.0.2, Android SDK Platform-tools 20 and Android SDK Build-tools 20 have all been verified to work correctly with the SDK. If you have problems compiling after an update, close the Android SDK Manager and re-open it to make sure you have everything required for the installed packages. In some cases you may get the warning Could not load definitions from resource emma_ant.properties. This is usually due to missing components in the install or improper file permissions. If the problem persists after verifying everything is up to date, try deleting the local.properties files from your project folders and updating them in each project folder with the command: android update project -p. Then rebuild. Verify Eclipse Configuration Verify that Eclipse has the proper location for your Android Development Tools. Launch the Eclipse executable which came with the ADT bundle, e.g.: C:\Dev\Android \android_adt_bundle_20140702\eclipse\eclipse.exe. 1. In the Eclipse menu go to Window -> Preferences -> Android. 2. The Android Preferences SDK Location should be set to the location where you installed the ADT bundle SDK in the previous section, e.g.: C:\Dev\Android\android_adt_bundle_20140702\sdk. Android Native Development Kit The Android Native Development Kit (NDK) is a toolset that allows you to implement parts of your app using native code languages such as C and C++. The NDK is used extensively by the sample applications which come with this release. The last version of the NDK known to work with the Mobile SDK is r10e. 1. Download the latest version of NDK at the following location: https://developer.android.com/tools/sdk/ndk/ index.html 2. Once downloaded, install NDK to your Android development folder, e.g.: C:\Dev\Android\android-ndkr10e\. 3. Add the NDK location to your PATH, e.g.: C:\Dev\Android\android-ndk-r10e\. 4. Add the environment variable ANDROID_NDK, which should be set to your Android NDK location, e.g.: C: \Dev\Android\android-ndk-r10e. set ANDROID_NDK=C:\Dev\Android\android-ndk-r10e Configure Eclipse for NDK Usage 1. Start Eclipse from the location it was installed to, e.g.: C:\Dev\Android\adt-bundle-windowsx86_64-20140702\eclipse\eclipse.exe. 2. Download and install the Eclipse ADT Plugin. 1. In the Eclipse menu go to: Help -> Install New Software. 2. Click Add in the top-right corner.

Mobile Mobile SDK Setup Guide 31 3. In the Add Repository dialog that appears, enter ADT Plugin in the Name field and the following URL: https://dl-ssl.google.com/android/eclipse 4. Click OK. 5. In the Available Software dialog, select the checkbox for Developer Tools and click Next. 6. Click OK. 7. In the next window, you will see a list of tools to be download. Click Next. 8. Read and accept the license agreements, then click Finish. Click OK if you get any prompts regarding the security and authenticity of the software. 9. When the installation completes, restart Eclipse. 3. Configure the NDK path: 1. In the Eclipse menu, go to: Window -> Preferences -> Android. 2. Under Android, select NDK. 3. Set the NDK Location field to the directory where the NDK is installed. If the NDK option under the Android section is missing, something went wrong with the Eclipse ADT Plugin installation. Full instructions and troubleshooting information may be found here: http:// developer.android.com/sdk/installing/installing-adt.html#troubleshooting Apache Ant Apache Ant is a Java library and command-line build system. It provides a number of built-in tasks which simplify building Java projects. The Apache Ant project is part of the Apache Software Foundation. The latest version which has been tested with this release is Apache Ant 1.9.4. It is available for download at the following location: http://ant.apache.org/bindownload.cgi Note: The Ant download page is explicit about verifying the Ant binary, but this is not strictly necessary for using Ant or for getting Android development up and running. Once downloaded, unpack the zip file and save to your Android development folder, e.g.: C:/Dev/Android/ apache-ant-1.9.4.

32 Mobile SDK Setup Guide Mobile Next, add the Ant bin folder to your PATH, e.g.: C:\Dev\Android\apache-ant-1.9.4\bin. For more information on using Ant to automate building Android Apps, see: http:// www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html Android Eclipse Development Software Setup for OS X In order to develop Android applications, you must have the following software installed on your system: 1. 2. 3. 4. Xcode Android Development Tools (ADT) Bundle Android Native Development Kit (NDK) Apache Ant Note: The tilde character followed by a forward slash (~/) is shorthand for the current user s home folder. It is used throughout this section. Xcode Before installing any Android development tools, you must install Xcode. Once Xcode is installed, some of the following steps (such as installing Apache Ant or the JDK) may be unnecessary - some versions of OS X (10.5 and later) include Apache Ant, and some do not. On Mavericks 10.9, Ant does not appear to be installed by default or included with Xcode 5.0.2. Java Development Kit The Java Development Kit (JDK 8) is a prerequisite for the Android Eclipse IDE (included with the ADT Bundle) as well as Apache Ant. Install the JDK if it is not already present on your system. If you already installed Xcode, this step may be unnecessary. The latest version tested with this release is JDK 8 - it may be downloaded at the following location: http:// www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Android Development Tools Bundle The Android Development Tools ADT Bundle includes almost everything needed to begin developing Android Apps. The ADT Bundle includes: Android SDK Tools Android Platform Tools Latest Android Platform Eclipse with integrated ADT Plugin Latest System Image for Emulator For information on downloading and installing ADT, see http://developer.android.com/sdk/installing/installingadt.html. The ADT bundle comes in either a 32-bit or 64-bit version. This must match the JDK option you selected above.

Mobile Mobile SDK Setup Guide 33 Installing Additional Packages and Tools The Android SDK does not include everything you will need for development by default. You will need to download additional packages via the SDK Manager before you begin. In Eclipse go to Window -> Android SDK Manager to open a window similar to the following: 1. Note that some packages are already selected for installation by default. Leave these projects selected. 2. If not already selected under Tools, select Android SDK Tools, Android SDK Platform-tools, and Android SDK Build-tools. 3. Open Android 4.4.2 (API 19) and select the items for SDK Platform and ARM EABI v7a System Image under it. 4. Click Install X Packages, where X is the number of selected packages (it may vary based on what needs to be updated). 5. On the next dialog, choose Accept License. 6. Click Install to install and update packages. You may install additional packages above API 19 if you wish. Android SDK Tools 23.0.2, Android SDK Platform-tools 20 and Android SDK Build-tools 20 have all been verified to work correctly with the SDK. Android Native Development Kit The 2.4 Android Native Development Kit (NDK) is a toolset that allows you to implement parts of your app using native code languages such as C and C++. It is used extensively by the sample applications which come with this release. The latest version which has been tested with this release is NDK r10e - it is available for download at the following location: https://developer.android.com/tools/sdk/ndk/index.html. Once downloaded, extract the NDK to your home/dev folder (~/dev). Your dev folder should look something like the following:

34 Mobile SDK Setup Guide Mobile Note that the ADT bundle and the NDK are extracted into their own folders within the Dev folder (in this case, folders that were in the root of their archive). The names of the folders, where the ADT bundle and the NDK reside, are not vitally important. As long as they are in separate folders and are not extracted directly into the Dev folder, any conflict between the two packages can be avoided. It is recommended you use the above naming scheme so that there is no question which version of the ADT bundle and the NDK are installed. You can read more about installation and use of the NDK here: http://developer.android.com/tools/sdk/ndk/ index.html#installing. Configure Eclipse for NDK Usage 1. Launch Eclipse and go to the Eclipse -> Preferences window. 2. Under Android, verify that Eclipse knows the location of the Android Development Tools. If the NDK option is missing in the Preferences -> Android section, update the Eclipse ADT Plugin as follows. 1. Download and install the Eclipse ADT Plugin. a. In the Eclipse menu go to: Help->Install New Software. b. Click Add in the top-right corner. c. In the Add Repository dialog that appears, enter ADT Plugin in the Name field and the following URL: https://dl-ssl.google.com/android/eclipse d. Click OK. e. In the Available Software dialog, select the checkbox for Developer Tools and click Next. f. Click OK. g. In the next window, you will see a list of tools to be download. Click Next. h. Read and accept the license agreements, then click Finish. Click OK if you get any prompts regarding the security and authenticity of the software. i. When the installation completes, restart Eclipse. 2. Configure the NDK path. a. In the Eclipse menu go to: Window -> Preferences -> Android. b. Under Android select NDK. c. Set the NDK Location field to the directory where the NDK is installed.