[Bug]: Android app crashes - createPack() throwing error while downloading and app crashes on getPacks()
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Mapbox Version
11.8.0
React Native Version
0.77.0
Platform
Android
@rnmapbox/maps version
10.1.45
Standalone component to reproduce
import React, { useEffect } from 'react';
import MapboxGL, {
MapView,
ShapeSource,
LineLayer,
Camera,
} from '@rnmapbox/maps';
const DownloadOfflineMap = () => {
const RegionId = 'offline-region-1';
const bounds = [
[73.90, 18.45], // southwest [longitude, latitude]
[74.05, 18.55], // northeast [longitude, latitude]
];
const offlinePackOptions = {
name: RegionId,
styleURL: MapboxGL.StyleURL.Street,
bounds,
minZoom: 10,
maxZoom: 15,
metadata: {
regionId: RegionId,
downloadedAt: new Date().toISOString(),
version: '1.0',
},
};
useEffect(() => {
createPack();
}, []);
const createPack = async () => {
try {
await MapboxGL.offlineManager.createPack(
offlinePackOptions,
(offlineRegion, status) =>
console.log('Download progress:', status),
(error) =>
console.error('Failed to download region:', error)
);
} catch (error) {
console.error('Create pack error:', error);
}
};
return null; // No UI rendered
};
export default DownloadOfflineMap;
Observed behavior and steps to reproduce
For offline usage, we create and download regions using MapboxGL.offlineManager.createPack(), and then access the downloaded regions using MapboxGL.offlineManager.getPacks() to display the map and calculate routes in offline mode.
This flow works correctly on iOS — the region downloads successfully, and we can view the map offline without issues.
However, on Android, createPack() throws an error during the download process, and the offline packs are not downloaded completely. Because of this incomplete download, the app crashes when getPacks() is called while trying to open the downloaded region.
Steps to Reproduce
- Integrate rnmapbox/maps into a React Native project
- Configure Mapbox access token and initialize the Mapbox map
- Define a region (bounds, zoom levels, style URL) for offline download
- Call MapboxGL.offlineManager.createPack() to start downloading the offline region
- Observe that the download starts but fails or throws an error on Android
- Navigate to the screen where offline regions are loaded
- Call MapboxGL.offlineManager.getPacks() to retrieve downloaded packs
- App crashes on Android because the offline pack is partially downloaded
Expected behavior
- createPack() should successfully download the offline region on Android
- getPacks() should return only fully downloaded packs
- Offline maps and route calculation should work without crashes
Notes / preliminary analysis
No response
Additional links and references
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Android flow with the provided createPack() options, then inspect the error raised during download and the subsequent getPacks() call. Compare the Android behavior with the working iOS flow and trace how incomplete packs are handled. Done means the region downloads fully, getPacks() excludes incomplete packs, and offline map usage does not crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript, kotlin, react-native
- Domain
- mobile, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100