> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/help/llms.txt)

# Switch from Google Maps SDK for Android to Mapbox Maps SDK for Android

Are you using the **Google Maps SDK for Android** and want to switch to the **Mapbox Maps SDK for Android**? This tutorial walks through the core mapping concepts side by side, showing you the Google approach alongside the equivalent Mapbox implementation at each step.

In this tutorial, you will:

-   Add the Mapbox Maps SDK for Android to your app
-   Initialize a map with Jetpack Compose
-   Add a marker to the map
-   Show marker details when a user taps it

This screenshot shows the final product you will build in this tutorial.

![Screenshot of an Android app showing the Ferry Building, Golden Gate Bridge, and Alcatraz Island markers in San Francisco](https://docs.mapbox.com/help/assets/ideal-img/tutorials--android-google-migration-2.c7789e5.480.png)

## Prerequisites

This guide assumes familiarity with Kotlin and Android development and that you already have an app built with the Google Maps SDK for Android. Beginner experience with Jetpack Compose is helpful but not required.

To complete this tutorial, you will need:

-   **A Mapbox access token**: Find yours on the [Access token page](https://console.mapbox.com/account/access-tokens/) of your Mapbox account.
-   **Android Studio**: The latest version of [Android Studio](https://developer.android.com/studio/install) with Gradle and the Android SDK installed.
-   **A working Getting started app**: A Jetpack Compose Android app already configured with the Mapbox Maps SDK for Android and showing a globe, as described in the [Getting started with the Maps SDK for Android](https://docs.mapbox.com/android/maps/guides/install/) guide.

![Screenshot of an Android app showing a globe.](https://docs.mapbox.com/help/assets/ideal-img/tutorials--android-geofencing-1.8df3c0d.480.png)

## Initialize a map

Both SDKs render a map inside a container that you add to your app's UI. The APIs look different, but the goal is the same: show a map centered on a location.

This tutorial assumes you have followed the [Getting started with the Maps SDK for Android](https://docs.mapbox.com/android/maps/guides/install/) guide. This guide will leave you with a new Compose project open in Android showing a globe.

![Screenshot of an Android app showing a globe.](https://docs.mapbox.com/help/assets/ideal-img/tutorials--android-geofencing-1.8df3c0d.480.png)

### Google Maps SDK for Android

With Google Maps, you added a `SupportMapFragment` to your layout and configured the map when `onMapReady()` fires:

```kotlin
package com.example.googlemapsapp

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng

class MainActivity : AppCompatActivity(), OnMapReadyCallback {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val mapFragment = supportFragmentManager
            .findFragmentById(R.id.map) as SupportMapFragment
        mapFragment.getMapAsync(this)
    }

    override fun onMapReady(googleMap: com.google.android.gms.maps.GoogleMap) {
        val sanFrancisco = LatLng(37.7749, -122.4194)
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sanFrancisco, 12f))
```

### Mapbox Maps SDK for Android

With Mapbox, you add a `MapboxMap` composable inside `setContent` and configure the camera state directly:

```kotlin
package com.example.mapboxapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import com.mapbox.geojson.Point
import com.mapbox.maps.extension.compose.MapboxMap
import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MapboxMap(
                Modifier.fillMaxSize(),
                mapViewportState = rememberMapViewportState {
                    setCameraOptions {
                        center(Point.fromLngLat(-122.4194, 37.7749))
                        zoom(12.0)
                        pitch(0.0)
                        bearing(0.0)
                    }
                }
            )
        }
    }
}
```

Run the app to see a full-screen map centered on San Francisco.

![Screenshot of an Android app showing a map of San Francisco.](https://docs.mapbox.com/help/assets/ideal-img/tutorials--android-google-migration-1.c392d25.480.png)

Key differences:

-   **Map initialization**: Google uses a `MapFragment` and `OnMapReadyCallback`; Mapbox uses Compose and a `MapboxMap` composable.
-   **Coordinates**: Google uses `LatLng(lat, lng)`. Mapbox uses `Point.fromLngLat(lng, lat)`, matching GeoJSON ordering.
-   **UI setup**: Google often uses XML layout and fragment lookup, while Mapbox puts the map directly in the Compose UI tree.

## Add markers and callouts

Now you are ready to add multiple markers and show marker details when a user taps one.

### Google Maps SDK for Android

With Google Maps, created a list of San Francisco locations, added a marker for each one, and showed a `Toast` when the user taps a marker.

```kotlin
//...
private data class MapLocation(val position: LatLng, val title: String, val subtitle: String)

private val mapLocations = listOf(
    MapLocation(LatLng(37.7955, -122.3937), "Ferry Building", "San Francisco, CA"),
    MapLocation(LatLng(37.8199, -122.4783), "Golden Gate Bridge", "San Francisco, CA"),
    MapLocation(LatLng(37.8267, -122.4230), "Alcatraz Island", "San Francisco Bay")
)

private val cameraCenter = LatLng(37.8140, -122.4317)

@Composable
fun MapScreen(modifier: Modifier = Modifier) {
    val context = LocalContext.current
    val lifecycleOwner = LocalLifecycleOwner.current
    val mapView = remember { MapView(context) }

    DisposableEffect(lifecycleOwner) {
        val observer = mapView.toLifecycleObserver()
        lifecycleOwner.lifecycle.addObserver(observer)
        onDispose { lifecycleOwner.lifecycle.removeObserver(observer) }
    }

    AndroidView(
        modifier = modifier.fillMaxSize(),
        factory = {
            mapView.onCreate(Bundle())
            mapView.getMapAsync { googleMap -> googleMap.setUpMap(context) }
            mapView
        }
    )
}

private fun GoogleMap.setUpMap(context: Context) {
    moveCamera(CameraUpdateFactory.newLatLngZoom(cameraCenter, 11f))

    val locationsByMarkerId = mutableMapOf<String, MapLocation>()
    mapLocations.forEach { location ->
        val marker = addMarker(
            MarkerOptions()
                .position(location.position)
                .title(location.title)
                .snippet(location.subtitle)
        )
        marker?.let { locationsByMarkerId[it.id] = location }
    }

    setOnMarkerClickListener { marker ->
        val location = locationsByMarkerId[marker.id]
        Toast.makeText(context, "${location?.title} — ${location?.subtitle}", Toast.LENGTH_SHORT).show()
        false
    }

    setOnMapClickListener { latLng ->
        Toast.makeText(
            context,
            "Tapped: %.4f, %.4f".format(latLng.latitude, latLng.longitude),
            Toast.LENGTH_SHORT
        ).show()
        true
    }
}
//...
```

### Mapbox Maps SDK for Android

With Mapbox, use a Compose-based map screen that places markers for the same San Francisco locations and shows a toast when each marker is tapped.

```kotlin
package com.example.mapboxapp

import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import com.example.tutorialtest.ui.theme.TutorialTestTheme
import com.mapbox.geojson.Point
import com.mapbox.maps.MapboxExperimental
import com.mapbox.maps.Style
import com.mapbox.maps.extension.compose.MapboxMap
import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState
import com.mapbox.maps.extension.compose.annotation.Marker
import com.mapbox.maps.extension.compose.style.MapStyle
import com.mapbox.maps.plugin.gestures.OnMapClickListener

private data class MapLocation(val point: Point, val title: String, val subtitle: String)

private val mapLocations = listOf(
    MapLocation(Point.fromLngLat(-122.3937, 37.7955), "Ferry Building", "San Francisco, CA"),
    MapLocation(Point.fromLngLat(-122.4783, 37.8199), "Golden Gate Bridge", "San Francisco, CA"),
    MapLocation(Point.fromLngLat(-122.4230, 37.8267), "Alcatraz Island", "San Francisco Bay")
)

private val cameraCenter = Point.fromLngLat(-122.4317, 37.8140)

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            TutorialTestTheme {
                MapScreen()
            }
        }
    }
}

@OptIn(MapboxExperimental::class)
@Composable
fun MapScreen(modifier: Modifier = Modifier) {
    val context = LocalContext.current

    val mapViewportState = rememberMapViewportState {
        setCameraOptions {
            center(cameraCenter)
            zoom(11.0)
        }
    }

    MapboxMap(
        modifier = modifier.fillMaxSize(),
        mapViewportState = mapViewportState,
        style = { MapStyle(style = Style.MAPBOX_STREETS) },
        onMapClickListener = OnMapClickListener { point ->
            Toast.makeText(
                context,
                "Tapped: %.4f, %.4f".format(point.latitude(), point.longitude()),
                Toast.LENGTH_SHORT
            ).show()
            true
        }
    ) {
        mapLocations.forEach { location ->
            Marker(
                point = location.point,
                text = location.title,
                onClick = {
                    Toast.makeText(context, "${location.title} — ${location.subtitle}", Toast.LENGTH_SHORT).show()
                    true
                }
            )
        }
    }
}
```

This section shows how both SDKs add the same three San Francisco markers and respond to user interaction. In Google Maps, the marker title and snippet provide information window content and tap events are handled through listeners. In Mapbox, each `Marker` includes a text label and its tap callback displays the selected location details.

Run the app to see the Ferry Building, Golden Gate Bridge, and Alcatraz Island markers in San Francisco.

![Screenshot of an Android app showing the Ferry Building, Golden Gate Bridge, and Alcatraz Island markers in San Francisco](https://docs.mapbox.com/help/assets/ideal-img/tutorials--android-google-migration-2.c7789e5.480.png)

## Next steps

**Congratulations!** You have switched a Google Maps SDK for Android workflow to the Mapbox Maps SDK for Android.

### What we covered

-   Adding the Mapbox Maps SDK for Android dependency and access token
-   Initializing a map with `MapboxMap` and `rememberMapViewportState`
-   Adding a `PointAnnotation` marker to the map
-   Showing marker details with a `ViewAnnotation`

Explore more Android mapping tutorials:

-   [Build an Android marker app using GeoJSON data](https://docs.mapbox.com/help/tutorials/android-markers-from-geojson/)
-   [Add Interactions to your Map in Android](https://docs.mapbox.com/help/tutorials/android-interactions/)
-   [Add Location Search to an Android app](https://docs.mapbox.com/help/tutorials/android-location-search/)
-   [Implement Geofencing in an Android App](https://docs.mapbox.com/help/tutorials/android-geofencing/)
-   [Build an Android marker app from a custom style and tileset](https://docs.mapbox.com/help/tutorials/android-marker-app-custom-style/)

> **Related content (guide): [Mapbox Maps SDK for Android](https://docs.mapbox.com/android/maps/guides/)**
> 
> Full guide documentation for the Mapbox Maps SDK for Android.

> **Related content (tutorial): [Use Offline Maps in an Android app](https://docs.mapbox.com/help/tutorials/android-offline-maps/)**
> 
> Learn how to download and use offline maps in your Android app with the Maps SDK for Android.

> **Related content (tutorial): [Run the Maps SDK for Android Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-android-examples-app/)**
> 
> Set up and run the Mapbox Maps SDK for Android examples app to explore more capabilities.