MapLibre GL Native for Android

Application Screenshot

MapLibre Native for Android is a library for embedding interactive map views with scalable, customizable vector maps onto Android devices.

Using MapLibre Native for Android with MapTiler Cloud maps gives you a beautiful and smooth experience from map browsing.

Get Started With MapLibre Native for Android

Create a new project

Open Android Studio and create a new project and choose the Empty Views Activity template.

In the “Language” dropdown, select “Kotlin” and keep the minimum API SDK to 24.

Add MapLibre SDK to the project

Add Maven central repository (optional)

The MapLibre Native package is available from Maven Central. New Android Studio projects have this repository enabled by default. If it is not enabled, you can add mavenCentral() to your project-level Gradle file (usually <project>/build.gradle).

allprojects {
    repositories {

Add MapLibre to your dependencies

Add the library as a dependency into your module Gradle file (usually <project>/<app-module>/build.gradle).

dependencies {
    implementation ''

Sync your Android project with Gradle files.

Add the layout for the map

Add a MapView to your layout XML file (usually <project>/<app-module>/src/main/res/layout/activity_main.xml).

Add your MapTiler API Key (Project properties)

Create a variable with your MapTiler API Key in the file (usually <project>/


Get your FREE API key

Replace YOUR_MAPTILER_API_KEY_HERE with your actual MapTiler API key.

build.gradle (Module: app)

Set variable in the module build.gradle to access it in activity or fragment (usually <project>/<app-module>/build.gradle).

android {

    defaultConfig {
        buildConfigField "String", "MAPTILER_API_KEY", "${MAPTILER_API_KEY}"


Explicitly tell grade to generate the BuildConfig file (optional)

Starting with android gradle plugin version 8, you now have to explicitly tell grade that you want to generate the BuildConfig file.

Add the buildConfig option to the module build.gradle file (usually <project>/<app-module>/build.gradle).

android {

    buildFeatures {
        buildConfig = true


Sync your Android project with Gradle files.

Initialize Map View

Initialize the MapView in your MainActivity file (usually <project>/<app-module>/src/main/res/layout/activity_main.xml) by following the example below:

import android.os.Bundle
import android.view.LayoutInflater
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView

class MainActivity : AppCompatActivity() {
    // Declare a variable for MapView
    private lateinit var mapView: MapView

    override fun onCreate(savedInstanceState: Bundle?) {

        //Get the API Key by app's BuildConfig
        val key = BuildConfig.MAPTILER_API_KEY

        // Find other maps in
        val mapId = "streets-v2"
        val styleUrl = "$mapId/style.json?key=$key"

        // Init MapLibre

        // Init layout view
        val inflater = LayoutInflater.from(this)
        val rootView = inflater.inflate(R.layout.activity_main, null)

        // Init the MapView
        mapView = rootView.findViewById(
        mapView.getMapAsync { map ->
            map.cameraPosition = CameraPosition.Builder().target(LatLng(0.0,0.0)).zoom(1.0).build()

    override fun onStart() {

    override fun onResume() {

    override fun onPause() {

    override fun onStop() {

    override fun onLowMemory() {

    override fun onDestroy() {

    override fun onSaveInstanceState(outState: Bundle) {

Build and run the app. If you run the app successfully, a map will be displayed, as seen in the screenshot below.

Application Screenshot

Get Started With MapLibre GL JS for React Native

You can also develop your applications using React Native.

Get Started React Native

Get Started With MapLibre GL JS for Flutter

You can also develop your applications using Flutter.

Get Started Flutter

API Reference

Visit Android API Documentation to view the MapLibre Native API for Android documentation.

Android SDK
On this page