cancel
Showing results for 
Search instead for 
Did you mean: 

Starting a new native project

diegurrio
Explorer
What is the standard way to start a new mobile development project? 
I personally find that the recommended script to spawn a new project leaves a lot of unnecessary things behind.
1 REPLY 1

Mitnainartinari
Protege
I found the best sample to base a new native project on was the VrCubeWorld_Framework sample. The cleanest way seemed to just create the most basic native setup from scratch, since the other samples and the script seemed like a big mess to me. Look in MainActivity.java for passing control to your native code (it's tiny). In onCreate it simply calls a native function. The native function (nativeSetAppInterface) is found at the bottom of VrCubeWorld_Framework.cpp, which itself calls ovr_PlatformInitializeAndroid to get things up and running (with your app ID), then creates a new instance of a VrAppInterface-derived C++ class. Simply override some VrAppInterface virtual functions, the two main ones being Frame and DrawEyeView. The header file App.h (at VrAppFramework/Include/App.h in the mobile SDK) has good documentation for the life cycle of a GearVR native app and each of the important virtual members. Everything you need is documented in that file.

In my gradle file, I link to libvrappframework.a, libvrapi.so, and libovrkernel.a for some basic functionality, as well as libstb.a, libminizip.a, and libsystemutils.a. I can't remember the role of all of them. For in-app purchases and leaderboards you need libovrplatform.so and liboculus_p2p.so from the platform SDK. 

I also think it's a pain to develop natively in Android Studio. Native support seems terrible. I do most of my development in Xcode (although I'd prefer Visual Studio), running my app as a desktop application, then just rebuild the same code in Android Studio when I want to test it in a VR environment.