In this tutorial, you will learn how to integrate Spatial SDK into a template Android phone app. You should start with the template app provided in this tutorial. However, if you already have an Android app, you can use it to follow along.
Before you begin
Complete the Hello World tutorial. It will ensure your environment and headset are set up correctly. Once you can successfully deploy a simple Spatial SDK app to your headset, return to this tutorial.
To support Spatial SDK, you are going to create a new build variant. This will allow you to have a mobile version of your app (for phones) and a Quest version (for Meta Quest devices). The same codebase can be used for mobile app development and immersive app development.
If your app uses Groovy (build.gradle instead of build.gradle.kts), read the build variant page for Groovy syntax.
In Android Studio, make sure the project view setting is set to Project Files and not Android.
Open the app/build.gradle.kts file.
Add the following code to the end of the the android block.
Copy src/main/AndroidManifest.xml to the src/mobile and src/quest folders.
Sync the project with Gradle.
To update your build variant to questDebug, select Build > Select Build Variant, and in the Build Variants window that appears, select questDebug as the active build variant.
Here’s a video showing the change:
Now your app will use src/quest/AndroidManifest.xml when building. If you switch the build variant back to one of the mobile flavors, then your app will use src/mobile/AndroidManifest.xml.