Android Studio Basics
This guide introduces the Android Studio IDE and reviews some basic features, including how to build and run sample projects.
Getting Started with Native Samples: Import Gradle Project
- If this is the first time you are launching Android Studio, select Open an existing Android Studio project. If you have launched Android Studio before, click File > Open instead.

- Open any
build.gradle
project file from the Mobile SDK VrSamples folders. For example, VrSamples/VrCubeworld_Framework/Projects/Android/build.gradle
.

- When asked if you would like the project to use the Gradle wrapper, click OK.

Troubleshooting Gradle Sync Errors
Here are some possible solutions if Android Studio reports a Gradle sync or configuration error:
- The most common cause of such an error is that the Android SDK or NDK locations are wrong. Verify that the SDK and NDK locations are specified correctly in File > Project Structure. If either are wrong or missing, you cannot continue until you fill in the correct path.
- On macOS, sometimes Android Studio reports a missing SDK location error even when the correct paths are listed in the Project Structure dialog box. To correct this problem, copy the
local.properties
file from your project folder up to the root of your Oculus Mobile SDK folder.

Android Studio displays project files in the Android view by default. We recommend changing it to the Project view, which provides a good overview of the entire directory structure and highlights imported project directories in bold.

Select Target Configuration, Build, and Run
Before building, select the target configuration you wish to build by selecting Edit Configurations in the project menu in the Android Studio toolbar.

To build and run your app:
Click Run in the toolbar.

- The Select Deployment Target dialog box appears. This is sometimes set to an emulator by default.
Select a device listed under Connected Device instead.

- If your device asks you to Allow USB debugging, click OK.
Troubleshooting: If USB debugging does not seem to be working:
- Go to Developer Options on your phone.
- Toggle USB Debugging off and then back on.
Troubleshooting: If stepping into certain functions results in an illegal instruction exception (SIGILL)/crash while debugging:
- In Android Studio, go to Run > Debug > Edit Configurations.
- Select the Debugger pane.
- Select the LLDB Post Attach Commands pane.
- Click + to add a new command.
- Add the following command:
process handle --pass true --stop false --notify true SIGILL
If you edit a *.gradle
file or install an update to the Oculus Mobile SDK which includes updated Gradle projects, click Sync Project with Gradle Files to update your Android Studio project files.
