Develop
Develop
Select your platform

Create a Quest build variant

Updated: Oct 9, 2024
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.

Step 1: Download the template Android app

Download the template Android phone app from this GitHub repository.

Step 2: Open and run the template app

Once you’ve downloaded the template app, open it in Android Studio. You can run it on a physical Android device, or on the Android emulator.
Here’s an example of what you should see:
Screenshot of the emulator running the sample app
“(c) copyright 2008, Blender Foundation, www.blender.org”

Step 3: Add a Meta Quest build variant

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.
  1. In Android Studio, make sure the project view setting is set to Project Files and not Android.
  2. Open the app/build.gradle.kts file.
  3. Add the following code to the end of the the android block.
     buildFeatures { buildConfig = true }
     flavorDimensions += "device"
     productFlavors {
       create("mobile") { dimension = "device" }
       create("quest") { dimension = "device" }
       }
    
    The full android block should now look like this:
     android {
       namespace = "com.meta.media.template"
       compileSdk = 34
    
       defaultConfig {
         applicationId = "com.meta.media.template"
         // Meta Spatial SDK require 28 for minimum SDK version.
         minSdk = 29
         targetSdk = 33
         versionCode = 1
         versionName = "1.0"
    
         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
       }
    
       buildTypes {
         release {
           isMinifyEnabled = false
           proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
         }
       }
       compileOptions {
         sourceCompatibility = JavaVersion.VERSION_17
         targetCompatibility = JavaVersion.VERSION_17
       }
       kotlinOptions { jvmTarget = "17" }
    
       buildFeatures { buildConfig = true }
       flavorDimensions += "device"
       productFlavors {
         create("mobile") { dimension = "device" }
         create("quest") { dimension = "device" }
         }
     }
    
  4. Copy src/main/AndroidManifest.xml to the src/mobile and src/quest folders.
    Screenshot of AndroidManifest.xml in the mobile and quest folders
  5. Sync the project with Gradle.
    GIF of the Gradle sync icon being clicked
  6. 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.

Next steps

Did you find this page helpful?