This website uses cookies to improve our services and deliver relevant ads.
By interacting with this site, you agree to this use. For more information, see our Cookies Policy

Native C/C++ (Gear VR) Getting Started

Get started using Oculus Avatars in native GearVR code by creating an avatar project using the Native Application Framework Template.

Download and Prepare Oculus SDKs

Our SDKs are packaged in .zip files on our developer website.

  1. Download the Oculus Avatars SDK .zip package from https://developer.oculus.com/downloads/ and then extract the contents to C:\dev.
  2. Download the Oculus Mobile SDK .zip package from https://developer.oculus.com/downloads/ extract the contents to C:\dev, and then rename the ovr_sdk_mobile_x.x.x folder to ovr_sdk_mobile.
  3. Download the Oculus Platform SDK .zip package from https://developer.oculus.com/downloads/ extract the contents to C:\dev, and then rename the OVRPlatformSDK_vx.x.x folder to OVRPlatformSDK.
  4. Save the following code as C:\dev\OVRPlatformSDK\Android\jni\Android.mk:
    LOCAL_PATH := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE := libovrplatformloader
    LOCAL_SRC_FILES := ../libs/$(TARGET_ARCH_ABI)/$(LOCAL_MODULE).so
    LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../Include
    ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_SRC_FILES)))
      include $(PREBUILT_SHARED_LIBRARY)
      endif

Create a New App Using the Application Framework

Use the Native Application Framework Template to create a new Gear VR project called "mirror" and place your Android device OSIG file inside the assets folder.

  1. Run these commands from a Windows command prompt:
    cd C:\dev\ovr_sdk_mobile\VrSamples\Native\VrTemplate
    make_new_project.bat mirror oculus
  2. Connect your Android device to your computer.
  3. Create an Oculus Signature File for your Android device at https://dashboard.oculus.com/tools/osig-generator/and then copy it to the folder C:\dev\ovr_sdk_mobile\VrSamples\Native\mirror\assets.

For more information, see Creating New Apps with the Framework Template.

Modify the Sample Code with a Gear VR App ID

The Avatar SDK Samples folder contains a Gear VR version of our Rift mirror sample. Because this sample uses Oculus platform calls, you must add your own Gear VR app ID to the sample code. This app ID must be from a Gear VR app owned by your developer organization and your Oculus user must be subscribed to at least one release channel in that app.

  1. Copy the contents of C:\dev\OVRAvatarSDK\Samples\MirrorAndroid to C:\dev\ovr_sdk_mobile\VrSamples\Native\mirror\Src
  2. Change #define APP_ID "1221388694657274" in Src\OvrApp.cpp so that it contains the Gear VR app ID of an app that belongs to your developer organization.

Modify the Android.mk Makefile

We need to modify the Android.mk makefile with the paths to our sources and our Avatar and Platform SDK library files.

  1. Locate the Android.mk file in C:\dev\ovr_sdk_mobile\VrSamples\Native\mirror\Projects\Android\jni.
  2. Modify the contents of Android.mk as follows:
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

include ../../../../../cflags.mk

LOCAL_MODULE            := ovrapp
LOCAL_SRC_FILES         := ../../../Src/OvrApp.cpp ../../../Src/AvatarManager.cpp
LOCAL_STATIC_LIBRARIES  := vrsound vrmodel vrlocale vrgui vrappframework libovrkernel
LOCAL_SHARED_LIBRARIES  := vrapi libovrplatformloader libovravatarloader

include $(BUILD_SHARED_LIBRARY)

$(call import-module,LibOVRKernel/Projects/AndroidPrebuilt/jni)
$(call import-module,VrApi/Projects/AndroidPrebuilt/jni)
$(call import-module,VrAppFramework/Projects/AndroidPrebuilt/jni)
$(call import-module,VrAppSupport/VrGUI/Projects/AndroidPrebuilt/jni)
$(call import-module,VrAppSupport/VrLocale/Projects/AndroidPrebuilt/jni)
$(call import-module,VrAppSupport/VrModel/Projects/AndroidPrebuilt/jni)
$(call import-module,VrAppSupport/VrSound/Projects/AndroidPrebuilt/jni)
$(call import-module,../OVRPlatformSDK/Android/jni)
$(call import-module,../OVRAvatarSDK/Android/jni)

Build and Launch the Project

Run C:\dev\ovr_sdk_mobile\VrSamples\Native\mirror\Projects\Android\build.bat to build and launch the app on your device.