Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Step Debugging on the GearVR

weinbergercweinbergerc Posts: 5
edited February 2016 in Oculus Go Development
I have been trying to get it to work for ages.

I'm seemingly doing everything...

1. Using android studio...
2. Made a "Native Project" using edit configurations
3. Added the symbol directory in edit configurations (\VrSamples\Native\VrCubeWorls_NativeActivity\Projects\Android\obj\local\armeabi-v7a\objs-debug\vrcubeworld\_\_\_\Src)
4. Connected via USB
5. GearVr developer mode enabled on the device
6. Set breakpoint
7. Hit debug in Android Studio

When the application launches on the device a screen pops up and says "Waiting for the debugger" and then I do see "Connected to the target VM, address: 'localhost:8600', transport: 'socket'" in android studio. But the breakpoint never hits. Why??


  • 8bit8bit Posts: 94 Oculus Start Member
    Hello @weinbergerc,

    I had a similar experience and believe that this is because Android Studio NDK development is still kind of Beta. Although I have heard people have had more success with Visual Studio NDK development.

    For reference here is a thread I started early talking about the same thing:

    If I am wrong, please do correct me. :)
  • mbehenskymbehensky Posts: 8
    Hi, all-

    I'm having the same problem. I followed the steps in the mobile sdk documentation to the letter, and am able to build the native vrsamples and run them either stand-alone or in the debugger on my GearVR. However, I can't get the debugger to hit a breakpoint no matter what I do. I can hit the pause button and stop the program running (although you have to hit the pause button twice, for some reason), however there is no ability to see what is going on in the program at all. Yes, I have set the symbol directories properly (at least as far as I can tell).

    I had earlier problems with run-as permissions; however, this is not the problem now (see my thread on the subject). I am now happily able to debug the (non-gearvr) native teapot application sample that distributes with Android Studio.

    This is extremely frustrating, given that the oculus developer website has a screenshot that clearly shows the VrCubeworld_Framework sample stopped at a breakpoint, with values for local variables displayed.

    Presumably, this was with some earlier version of Android Studio, or an earlier version of the Mobile SDK, or an earlier version of one of the SDK tools. I am using Android Studio 1.5, and have tried installing earlier versions. 1.4 has the same problem. I haven't been able to get 1.3 to work after installation. I'm trying 1.2 now, without much hope.

    I'm now going to try and add GearVR support to the debuggable NativeTeapot sample application and see if that is possible. Given how hairy the build process seems to be for the GearVR, I think this may be a huge task.

    If anyone out there has been able to get this to work, a detailed step by step procedure would be hugely appreciated.

    It doesn't seem like too much to ask to have a procedure that actually works to build and debug a native application on the GearVR.
  • mbehenskymbehensky Posts: 8
    All right, thanks to other posts on this forum, particularly viewtopic.php?f=67&t=27431 I managed to get it to sort of work on Windows, anyway. Here's a step by step procedure that I tested after removing studio, the SDK, gradle, and all versions of Java I had installed. Hopefully it will work for you.

    1. Install the Java JDK. I used the 64 bit current version, which is 1.8.0_74 (available here: http://www.oracle.com/technetwork/java/ ... 33151.html )
    Make a note of where it got installed (mine was in c:\Program Files\Java\1.8.0_74)

    2. Install Android Studio and the Android SDK. I used the 1.5 version with both the IDE and SDK, available at: http://tools.android.com/download/studio/builds/1-5

    Since I have a smaller C: SSD with my operating system on it, I installed both Android Studio and the SDK into e:\Android\Android Studio and e:\Android\sdk respectively. Make sure you note where the SDK got installed.

    3. Install the NDK. The recommended version is android-ndk-r10e, available here: http://developer.android.com/ndk/downloads/index.html

    To do the install, download the exe file (I used the 64 bit version) and copy it to your Android directory. Double click and it will self-extract. Make a note of where you put it.

    4. Install gradle version 2.8. You can download it here: http://gradle.org/gradle-download/

    You may not have to do this if you don't want to build from the command line, I'm not sure. Remember where you put it; I stuck it in e:\Android to keep everything together.

    5. Set up the environment variables. I put them in the system environment section, but you could maybe put them in the section for your specific user. I set the following variables. Modify these based on the places you installed things:

    JAVA_HOME=c:\Program Files\Java\jdk1.8.0_74

    You also need to add entries to your path for all this stuff. You may not need to add all these entries if you don't want to be able to build from the command line. Here's what I added. Modify the gradle path entry based on where you put gradle:


    Make sure you click OK after you edit the environment variables or nothing will change.

    6. Install the GearVR mobile SDK. You can find it here: https://developer.oculus.com/

    I extracted the zip file into e:\Oculus\Mobile

    7. Now, run android studio. It will try and update various things. I let it do this. Go into the stand alone SDK manager and add build tools 22.0.1 (you may have to check the Obsolete box).

    At this point, you can hopefully build from the command line (Note that you need to open a new window every time you change environment variables or the changes won't get recognized).

    Change directory to VrSamples\Native\VrCubeWorld_Framework\Projects\Android in whatever place you put your oculus mobile sdk. Plug in your phone with USP and try running "adb devices" and you should see your phone listed. Make sure debugging is authorized. If it doesn't list your phone, you need to enable debugging on the phone or fix your Samsung USB drivers.

    Create your developer key for your phone on the oculus website using the code you see in the device list. Copy the file to VrSamples\Native\VrCubeWorld_Framework\assets

    If you type build in the command window now, the program should build, download to your phone, and start running. If you have your Gear service in developer mode the program will start right up. If your GearVR service is in normal mode you will have to put your phone into the GearVR to see the cubes.

    8. Now you should be able to start up android studio, and import the build.gradle project file in the mobile SDK directory. For info on how to do this, check out here: https://developer.oculus.com/documentat ... io-basics/

    If you then select the VrCubeWorld_Framework Projects choice from the menu at the top and hit the Run button the framework project will hopefully build, download, and run just like in the command line section. If you try and debug it, however, you will be in Java debug mode and won't have access to any of the native code.

    To debug native code, you must first set up a native code run/debug configuration. First, look at the documentation on the Oculus website here:
    https://developer.oculus.com/documentat ... dio-debug/

    This is a little out of date, but will give you the right general idea. To add a native configuration hit "Edit Configurations" from the menu at the top, and then hit the "+" sign. Select Android Native. Select VrCubeWorld_Framework-Projects-Android in the Module box. Give the configuration a name like VrCubeWorld_Framework Native. Click on the "Native Debugger" tab and hit "+" in the Symbol Directories box. Browse to the VrSamples\Native\VrCubeWorld\Projects\Android\obj\local\armeabi-v7a directory.

    I think it is good to un-check the "Hybrid Debugging" box (this seems to re-check itself sometimes). If you leave it checked it runs a java debugger as well, which increases confusion and isn't helpful at this point.

    Put your GearVR service on your phone into debug mode .

    Now you can select your new configuration in the box at the top and hit the debug button. Your program will run under the debugger. You won't be able to put any breakpoints into your source code, however. If you hit the "Pause" button twice you will be able to pause the program, but you won't be able to do anything.

    9. The problem seems to have something to do with Android Studio running the 64 bit version of the debugger when it should be running the 32 bit version. There may be a better way to fix this, but one way that works is to just remove the 64 bit debugger from the Android Studio directory. Exit Android Studio, go to your android studio directory and move the arm64-v8a directory from Android Studio\bin\lldb\android someplace else (like into the top level android directory. You could just delete it, but then if you ever wanted to debug a real 64 bit application you would be screwed.

    Once you do this, you can re-start android studio and you should be able to debug somewhat better. I have been unable to place a breakpoint in the source code editor, but you can do it this way:

    Hit the pause button in the debugger (you may have to do it twice).
    When the program stops, click on the lldb tab in the debugger window.
    Hit return until you get a (lldb) prompt.
    br set -M VrCubeWorld::Frame

    Hit the Resume Program button on the debugger window. Your program will hit the breakpoint at the beginning of the Frame function, and you can then single step, look at variables, etc. You may need to open the VrCubeWorld_Framework.cpp file in the editor to see which line your program is stopped at. Change the view mode to Project, and browse around in the project window until you find the file in VrSamples\Native\VrCubeWorld_Framework\Src.

    Good Luck..

    Max Behensky
Sign In or Register to comment.