Develop
Develop
Select your platform

Auto-create product flavors

Updated: Sep 12, 2025
With Android’s product flavors, you can use the same codebase to support mobile and Quest devices. Each product flavor creates its own APK file and can have its own source code, manifest, and dependencies. Product flavors will share common code and dependencies.

Automatically create product flavors using Android Studio

You can use the Meta Horizon Android Studio Plugin to automatically set up product flavors for your project. The plugin provides a simple way to configure your Android project with the necessary product flavors for both mobile and Quest devices.
To use the plugin:
The plugin will automatically add the required configuration to your Gradle files and create the necessary directory structure for your project.
Meta Horizon Tool Window showing the product flavor generation button location

Switch the active product flavor

Android Studio can only track one “active” product flavor at a time. It will ignore source files in inactive product flavors, and will not analyze them for errors.
To change the active build variant, use the Build Variants tool window. Changing the current build variant will re-sync your Gradle project.

Add flavor-specific dependencies

You can include modules in only one product flavor. This will minimize the size of your apps and help prevent you from writing code that’s incompatible with your target device.
In the example below, AndroidX core is in all product flavors, Google Play billing services is in the mobile flavor, and Quest’s billing compatibility SDK is in the quest flavor.
// app/build.gradle.kts
dependencies {
 implementation(libs.androidx.core.ktx)
 "mobileImplementation"(libs.billing)
 "mobileImplementation"(libs.billing.ktx)
 "questImplementation"(libs.horizon.billing.compatibility)
}

// app/build.gradle
dependencies {
   implementation libs.androidx.core.ktx
   mobileImplementation libs.billing
   mobileImplementation libs.billing.ktx
   questImplementation libs.horizon.billing.compatibility
}

Add flavor-specific manifests

Each product flavor gets its own source directory, based on the name of the product flavor. Each flavor can have its own manifest file:
  • app/src
    • main
      • AndroidManifest.xml
      • java/…
      • res/…
    • quest
      • AndroidManifest.xml
    • mobile
      • AndroidManifest.xml
Manifests are merged according to Android’s merge rules. This means you can supply Quest-specific metadata in quest/AndroidManifest.xml, mobile-specific permissions in mobile/AndroidManifest.xml, and common information in main/AndroidManifest.xml.

Add flavor-specific source files

Flavors can also have their own source files and resources. This allows different product flavors to have different implementations of the same backend interface:
  • app/src
    • main
      • AndroidManifest.xml
      • java/…
        • BillingUser.kt
      • res/…
    • quest
      • java/…
        • Billing.kt
      • AndroidManifest.xml
    • mobile
      • java/…
        • Billing.kt
      • AndroidManifest.xml
In the example above, quest/java/Billing.kt and mobile/java/Billing.kt have the same interfaces, and respectively use Horizon and Google billing libraries. BillingUser.kt uses quest/java/Billing.kt on Meta Horizon OS and mobile/java/Billing.kt on mobile devices.
Did you find this page helpful?