Testing your app on a real device prior to releasing it to users is an imperative step in software development lifecycle. This topic describes how to set up your Oculus device for testing and debugging your app on Oculus device.
Depending on the Oculus device, you can choose different ways to test your app. In general, connecting your device through USB is the basic and mandatory way to test your app on the Oculus device. In addition, you can optionally use Android Debug Bridge (ADB) to perform advanced-level testing and debugging activities for Android apps.
You can run your app in the Oculus device to test its functionality, layout, and overall user experience. The Oculus device is connected to the computer over a USB cable. Prior to connecting the device and your computer, you need to set your device into developer mode.
The scene loads in the connected Oculus device.
Android Debug Bridge (ADB) is a command-line utility that lets you perform a variety of actions such as install and debug apps, copy files, or run several shell commands on the Oculus device. It is included with the Android SDK tools installation and located inside the /Android/SDK/platform-tools/ folder.
adb devices
Output:
List of devices attached
1PASH9BB939351 device
When you build an app in Unity, it creates a .apk file, which is an Android executable file. You can install the apk manually on your Oculus device for testing and debugging purposes by using ADB commands.
Sample command:
adb install -r /Users/username/Unity-Sample-Projects/ballgame/playgame.apk
Output:
Performing Streamed Install
Success
ADB is a versatile tool that lets you perform several debugging activities. There are a variety of adb commands that you can run on your Oculus device based on your requirement. For more information about learning ADB in detail and using its commands, go to Android Debug Bridge in the Android documentation.
Computer is unable to detect the Oculus device.
There can be many reasons why your computer is unable to detect the Oculus device. To begin with:
Ensure that you have turned on the developer mode in the Oculus companion app on your mobile.
Check if the issue is caused due to a faulty USB cable. Connect the device by using a secondary USB cable. If you do not have the secondary USB cable, connect any other Android device to verify if the issue is with the USB cable.
Ensure that your computer has all the necessary permissions to access your Oculus device. Typically, when you connect your device with the computer over a USB cable, you see a prompt to permit your computer to access the device. By mistake, if you have denied permission, disconnect the USB cable, restart the device, and then connect the cable again. When prompted for permission, click Allow.
Terminal returns an error: adb command not found.
Begin by verifying whether adb is correctly installed. Go to /Android/SDK/platform-tools/ folder and check for the adb tool. If the tool is missing, download the standalone Android SDK Platform-Tools package.
Check whether you’ve set the environment variables correctly.
You can run adb from the /Android/SDK/platform-tools/ folder by prefixing ./ to the adb command. For example, instead of adb devices, use ./adb devices.
If you have already set up your Oculus Rift for regular use, you are ready to begin Unity development.
While you build your app, Unity prompts you to provide location for the build, from where you can access the app for testing purposes. Considering you want to test your app, which is pending Oculus review, you must allow unknown sources on your device.