Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build Flavors

The rendering backend is selected at build time through Gradle product flavors. For OpenGL ES and Vulkan, there are also flavors that export the experimental C plugin API.

Overview

FlavorRendering backendPlugin APIStatusMaven Central artifactNotes
openglOpenGL ESNoStableorg.maplibre.gl:android-sdk-openglWidest device compatibility
vulkanVulkanNoStableorg.maplibre.gl:android-sdk-vulkan, org.maplibre.gl:android-sdkDefault, better performance on modern devices
multiBackendOpenGL ES + VulkanNoExperimentalorg.maplibre.gl:android-sdk-vulkan-openglBoth backends in one AAR, chosen at runtime
openglWithPluginApiOpenGL ESYesExperimentalorg.maplibre.gl:android-sdk-opengl-with-plugin-api
vulkanWithPluginApiVulkanYesExperimentalorg.maplibre.gl:android-sdk-vulkan-with-plugin-api, org.maplibre.gl:android-sdk-with-plugin-api
multiBackendWithPluginApiOpenGL ES + VulkanYesExperimentalorg.maplibre.gl:android-sdk-vulkan-opengl-with-plugin-api
webgpuDawnWebGPU (Dawn)NoExperimentalnot publishedUses Vulkan internally, see WebGPU
webgpuWgpuWebGPU (wgpu-native)NoExperimentalnot publishedUses Vulkan internally, arm64-v8a only, see WebGPU

Each published flavor also has a debug artifact, with a -debug postfix (e.g. android-sdk-vulkan-debug or android-sdk-opengl-with-plugin-api-debug).

The *WithPluginApi flavors are the same as the flavor they are named after, but their native library also exports the C plugin API (include/mln/plugin/plugin_api.h). The plugin API does not support WebGPU. The n-gon layer demo app in plugins/android uses these flavors.

Building a flavor

The flavor name is part of the Gradle task. For the test app:

cd platform/android

# OpenGL ES
./gradlew :MapLibreAndroidTestApp:installOpenglDebug

# Vulkan
./gradlew :MapLibreAndroidTestApp:installVulkanDebug

# WebGPU (Dawn)
./gradlew :MapLibreAndroidTestApp:installWebgpuDawnDebug

# WebGPU (wgpu-native)
./gradlew :MapLibreAndroidTestApp:installWebgpuWgpuDebug

# Both OpenGL ES and Vulkan, backend chosen at runtime
./gradlew :MapLibreAndroidTestApp:installMultiBackendDebug

The same pattern applies to the library module (MapLibreAndroid). Unlike the test app, it also has the *WithPluginApi flavors:

./gradlew :MapLibreAndroid:assembleVulkanRelease
./gradlew :MapLibreAndroid:assembleVulkanWithPluginApiRelease

Selecting in Android Studio

In Android Studio, use the Build Variants panel (View > Tool Windows > Build Variants) to pick the flavor. Each module will show a dropdown combining the flavor and build type, e.g. vulkanDebug or openglRelease.

How it works

Each flavor sets different CMake arguments:

  • opengl: -DMLN_WITH_OPENGL=ON
  • vulkan: -DMLN_WITH_VULKAN=ON
  • webgpuDawn: -DMLN_WITH_WEBGPU=ON, -DMLN_WEBGPU_IMPL_DAWN=ON
  • webgpuWgpu: -DMLN_WITH_WEBGPU=ON, -DMLN_WEBGPU_IMPL_WGPU=ON
  • multiBackend: -DMLN_ANDROID_MULTI_BACKEND=ON
  • *WithPluginApi: the arguments of the flavor they are named after, and -DMLN_WITH_PLUGINS=ON

Most flavors compile in only one backend, which is fixed for the lifetime of the app. multiBackend and multiBackendWithPluginApi are the exception - they ship both the OpenGL ES and Vulkan native libraries and pick one at runtime.

Renderer-specific Java code is split between flavor-specific source sets (src/opengl/, src/vulkan/, src/multiBackend/) and shared per-backend code in src/sharedRenderer/opengl/ and src/sharedRenderer/vulkan/. The *WithPluginApi flavors use the source sets of the flavor they are named after.