Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


30. December 2015

 

This is a tutorial on getting started with Samsung’s GearVRf framework with the Samsung Gear VR.  The GearVR is a virtual reality headset powered by Oculus Rift technology and a modern Samsung android phone.  The GearVRf SDK is a framework made available by Samsung enabling you to develop for the GearVR using Java.  If you are wondering “Hey, can’t you use Unity or Unreal Engine?” yes, yes you can and probably should… but that’s never stopped me from doing things before!

 

First off, there is a guide to getting started available here and it will get you *most* of the way there.  This tutorial covers the missing bits…  There is also a video version available here or embedded below.

 

First off there are a number or pre-requisites before you can begin, you need to have the following installed/configured/registered:

 

The Eclipse requirement is unfortunate, however NDK support was only recently added to Android Studio.  In time expect it to work with Android Studio instead.

 

As part of the installation, make note of where you extract the Oculus SDK.  The Samsung VR SDK has to be installed at the same directory level and I believe requires the folder be named ovr_sdk_mobile.  In other words, if you installed the Oculus Mobile SDK to c:\dev\ovr_sdk_mobile then clone GearVRf to the c:\dev folder. Change into the appropriate folder and run the command:

git clone https://github.com/Samsung/GearVRf.git

This will take a few minutes and download the GearVR SDK.  Now we are ready to start working in Eclipse.  Follow the instructions from Samsung specifically “Build Configuration” to setup Eclipse, then copy the files mentioned in the section “Oculus Mobile SDK”, it’s just 3 jars to 3 different folders that need to be copied.

 

Now we are ready to import the Samsung SDK into Eclipse.  Select File->Import… then Existing Android Code into Workspace.

image

 

Now select the Framework folder ( for example c:\dev\GVRf\Framework if you cloned the sdk into the c:\dev directory ), then click Next.

Go to the menu Project and turn off Build Automatically.  Then in the same menu select Clean… toggle if not already the “Clean all Projects” tick then click OK.  This will now build the SDK.  If you get an error, there is a good chance the your NDK or Android SDK settings in Eclipse are wrong, so start there.

 

Hopefully however everything ran fine.  In which case, let’s start with a sample from the SDK.  In the same workspace you imported and built the framework, import another existing Android project using the same settings, this time importing a project from Sample subdirectory of the GearVRf install folder. 

 

Now that we have a project to run, this next part is CRITICAL or your app will crash on start.  If you haven’t already, go to the Oculus site and register for a signing key ( the link is available above ) and put in the id of your phone.  Instructions are available on the same page as the form on Oculus.  This process will generate and download a file that needs to be included in each application you run.  Simply copy this file into the assets folder of the sample you imported.

 

Now plug in your phone then in Eclipse in Package Explorer, right click the imported demo and select Run As->Android Application. The APK should now be generated and copied to your phone.  However it wont run as you need to insert your device into the GearVR now ( we will address this shortly ).  For now, unplug your phone, run your newly installed app, then insert into the GearVR.  If it loads the main menu, your application crashed.  Ideally your app will now be running. 

 

So that’s it, the steps required to get started with GearVR development using Samsung’s GearVRf SDK.  If you are thinking… Unity/Unreal would be a hell of a lot easier!  You are right… I’ll cover getting started with both of those in the near future.

 

Now that we are running you will quickly notice that putting the device into the GearVR over and over is a pain and requires you to disconnect your device from USB each time making debugging impossible.  Don’t worry, there are two ways around this.

 

Debugging a Samsung Gear VR application

 

Running in Developer Mode ( no headset )

For most builds, you can actually run your code without a device.  This way you can leave it plugged in and remove the time consuming insert in phone and restart process.  First you need to put your phone into developer mode for Oculus.

  • Swipe down and select Settings gear icon
  • Tap Applications
  • Tap Application Manager
  • Locate Gear VR Service, tap
  • Tap Manage Storage
  • Tap VR Service Version Several times
  • Swipe Developer Mode on.  Now you can run without the Rift (great way to record video by the way…)

There is a dedicated post and video on this topic now available here.

 

Debug Wireless

You can also set adb into wireless mode. 

  • On your phone select Settings->Wireless->Click your active connection, make note of your IP address
  • Open a terminal/command prompt and cd into your Android SDK folder\platform-tools
  • Plug in your phone
  • In the terminal/command prompt type adb tcpip 5555
  • Now connect to device wireless with adb connect 123.123.123.123 (<--- obviously, your IP address here)
  • Unplug your device.  At this point you may want to restart Eclipse.
  • Now you can run from Eclipse directly to the device without having to plug in.

 

Video

Programming ,

blog comments powered by Disqus

Month List

Popular Comments