Skip to content

[Bug]: Android Crash when using the standard mapbox style #4095

@LeunensMichiel

Description

@LeunensMichiel

Mapbox Implementation

Mapbox

Mapbox Version

11.16.6

React Native Version

0.81.4

React Native Architecture

New Architecture (Fabric/TurboModules)

Platform

Android

@rnmapbox/maps version

10.2.7

Standalone component to reproduce

import {
	Ref,
	memo,
	useCallback,
	useImperativeHandle,
	useLayoutEffect,
	useRef,
	useState
} from "react"
import React from 'react' 
import { Dimensions, Platform } from "react-native"
import { tw } from "@utils/ui"


import {
	Camera,
	LocationPuck,
	MapState,
	MapView,
	StyleImport,
	setAccessToken,
	setTelemetryEnabled
} from "@rnmapbox/maps"
import { Position } from "@rnmapbox/maps/lib/typescript/src/types/Position"

const DEFAULT_PADDING = {
	paddingTop: (Dimensions.get("window").height * 16) / 100,
	paddingBottom: (Dimensions.get("window").height * 16) / 100,
	paddingLeft: (Dimensions.get("window").width * 16) / 100,
	paddingRight: (Dimensions.get("window").width * 16) / 100
}

export const GEO_DEFAULT_REGION = {
	latitude: 47.374458,
	longitude: 8.541712,
	latitudeDelta: 0.02,
	longitudeDelta: 0.02
}

export const DiscoverMapView = memo(() => {
	const cameraRef = useRef<Camera>(null)
	const mapRef = useRef<MapView>(null)

	return (
		<MapView
			ref={mapRef}
			style={tw`flex-1`}
			projection="mercator"
			pitchEnabled={false}
			compassEnabled
			compassFadeWhenNorth
			scaleBarEnabled={false}
			accessibilityLabel="discover_map"
			attributionPosition={
				Platform.OS === "ios" ? { left: 0, bottom: 4 } : undefined
			}
			logoPosition={
				Platform.OS === "ios" ? { left: 40, bottom: 6 } : undefined
			}
			styleURL={ "mapbox://styles/mapbox/standard"}
		>
				<StyleImport
					id="basemap"
					existing
					config={
						{
							lightPreset: "day",
							theme: "monochrome",
							showPointOfInterestLabels: false,
							colorTrunks: "#e3e3e3",
							colorWater: "#c9c9c9",
							colorRoads: "#e1e1e1",
							colorMotorways: "#c3c3c3"
							// config is typed as [key: string]: string, which is incorrect (should support booleans and numbers too)
							// https://docs.mapbox.com/map-styles/standard/api/#standard
						} as never
					}
				/>
			<Camera
				ref={cameraRef}
				defaultSettings={{
					zoomLevel: 14,
					padding: DEFAULT_PADDING,
					animationMode: "flyTo",
					animationDuration: 300,
					centerCoordinate: [
						GEO_DEFAULT_REGION.longitude,
						GEO_DEFAULT_REGION.latitude
					]
				}}
			/>
			{/* There is also  <UserLocation />. Not clear what the difference is between this and LocationPuck.
				Seems LocationPuck supports the Heading of the user's location which seems handy,
				while UserLocation seems to use the device's default UserLocation rendering. Needs to be tested. */}
			<LocationPuck
				puckBearingEnabled
				puckBearing="heading"
				pulsing={{
					isEnabled: true,
					color: "teal",
					radius: 18.0
				}}
			/>
		</MapView>
	)})

DiscoverMapView.displayName = "DiscoverMapView"

Observed behavior and steps to reproduce

Just launch the app, it crashes. When I use "mapbox://styles/mapbox/light-v11" instead and hide the StyleImport tag, my app continues to work.

Using an up to date Android Emulator on my mac running Android 16 and Google Play 16kb support image

Expected behavior

No response

Notes / preliminary analysis

No response

Additional links and references

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions