Product flavors to target Quest devices
Updated: Dec 16, 2024
You can use the same codebase to generate both a native mobile Android app and a 2D Meta Quest app using the
productFlavor Android development feature. This enables you to have a separate AndroidManifest.xml file for each variant, where you can set specific activities and properties for each variant.
The code example below uses the flavors “mobile” and “quest”. The “mobile” flavor targets mobile devices, excluding specific immersive features for Meta Quest devices. The “quest” flavor targets Meta Quest devices and builds a version of the app for the Meta Horizon Store. The “quest” flavor includes changes for Quest devices and the immersive features it implements.
- Add
productFlavors
to build.gradle
:
// Within build.gradle.kts
android {
...
flavorDimensions += "device"
productFlavors {
create("mobile") { dimension = "device" }
create("quest") { dimension = "device" }
}
}
- Create separate
AndroidManifest.xml
files for each variant:
- Create two directories under
app/src
and name them with the flavor names (for example, app/src/mobile
for Android and app/src/quest
for Meta Quest). - Create two
AndroidManifest.xml
files within each of these directories. - Within the manifest file in Meta Quest, you can include all of the immersive activities, Meta Quest specific metadata, and more. The manifest within the mobile directory can hold all mobile-specific activities and metadata.
- Build and run the app for each variant:
- Open the Build Variants view by going to View > Tool Windows > Build Variants.
- Select questDebug or questRelease to build and run the Android variant.
Note: Before building for the first time, make sure to uninstall the previous app and rebuild the entire project.