maps icon indicating copy to clipboard operation
maps copied to clipboard

[Bug]: Expo 53: App Crashes immediately on open on Android

Open LukakHR opened this issue 7 months ago • 32 comments

Mapbox Implementation

Mapbox

Mapbox Version

10.7.0 and 11.0.0

React Native Version

0.79.2

Platform

Android

@rnmapbox/maps version

10.1.38

Standalone component to reproduce

import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@rnmapbox/maps';

const aLine = {
  type: 'LineString',
  coordinates: [
    [-74.00597, 40.71427],
    [-74.00697, 40.71527],
  ],
};

class BugReportExample extends React.Component {
  render() {
    return (
      <MapView style={{flex: 1}}>
        <Camera centerCoordinate={[-74.00597, 40.71427]} zoomLevel={14} />
        <ShapeSource id="idStreetLayer" shape={aLine}>
          <LineLayer id="idStreetLayer" />
        </ShapeSource>
      </MapView>
    );
  }
}

Observed behavior and steps to reproduce

The app crashes on open after installing Expo 52 and doing npx expo prebuild --clean. I tried upgrading to Expo 53, tried both version 10.x.x and 11.x.x of mapbox and tried the patch to fix the issue but nothing helped. I am attaching a log report from the emulator after running: adb logcat | grep -E "(mapbox-common|SIGSEGV)"

t.log

Expected behavior

No response

Notes / preliminary analysis

No response

Additional links and references

No response

LukakHR avatar May 15 '25 10:05 LukakHR

I've tried to install a clean project and it's still not working.

Steps to reproduce Create new project: npx create-expo-app@latest

Add @rnmapbox/maps: npx expo install @rnmapbox/maps

Add config to app.json in plugins array: [ "@rnmapbox/maps", { "RNMapboxMapsDownloadToken": "sk....." } ]

Run expo prebuild: npx expo prebuild --platform android

Run app for android: npx expo run:android

The app builds and installs properly but crashes immediately on open. I tried to find some errors in logcat and got these:

05-16 11:49:09.770 4171 4171 I MapboxInitializer: MapboxMapsInitializer create() is called 05-16 11:49:09.770 4171 4171 I MapboxInitializer: MapboxInitializer started MapboxMapsInitializerImpl initialization, attempt 1 05-16 11:49:09.806 4171 4171 F libc : Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x755d1ed52280 in tid 4171 (new_project.project), pid 4171 (new_project.project) 05-16 11:49:09.836 4189 4189 E crash_dump64: failed to get the guest state header for thread 4171: Bad address

Removing mapbox makes the project run perfectly well

LukakHR avatar May 16 '25 09:05 LukakHR

Same here

tomislavkrnic avatar May 16 '25 13:05 tomislavkrnic

Same here. Started to getting this crash after i've updated my Samsung S23 to One UI 7.0 (Android 15).

Expo: 52 @rnmapbox/maps: 10.1.33 Android: 15

UPD: does not crash if i use Mapbox SDK 11.12.1

konstmar-ion avatar May 19 '25 11:05 konstmar-ion

Still having issues. Ios is working fine but Android is the problem. Has anyone fixed it?

sanguu516 avatar May 27 '25 18:05 sanguu516

@sanguu516 there is RC version released 1-2 days ago git that a try

MariuzM avatar May 27 '25 19:05 MariuzM

This latest release, 10.1.39, does not fix the Android production crash. And, per the comment above about setting the Mapbox SDK version to (in expo) RNMapboxMapsVersion: "11.12.1" - I am still experiencing a crash in production.

RyanTG avatar May 30 '25 01:05 RyanTG

I tried 10.1.39 and RNMapboxMapsVersion: "11.12.1", neither fixed the issue

LukakHR avatar May 30 '25 15:05 LukakHR

Any Update on this?

LukasB-DEV avatar Jun 05 '25 06:06 LukasB-DEV

Clean install, Expo + MapBox (latest 10.1.39) doesn't work on Android. App crashes on open

tomislavkrnic avatar Jun 05 '25 09:06 tomislavkrnic

Strange for me it works ios and android tried multiple times clean instal no problem

MariuzM avatar Jun 05 '25 10:06 MariuzM

Strange for me it works ios and android tried multiple times clean instal no problem

What Version are you using?

LukasB-DEV avatar Jun 05 '25 11:06 LukasB-DEV

Strange for me it works ios and android tried multiple times clean instal no problem

thats strange. Can you give more information so I can understand what the difference is? I've tried it on multiple devices, my colleague's too...Android always crashes.

tomislavkrnic avatar Jun 05 '25 12:06 tomislavkrnic

I only tried on the virtual devices not real ones,

maybe this help

 "dependencies": {
    "@gorhom/bottom-sheet": "^5.1.5",
    "@rnmapbox/maps": "^10.1.39",
    "@turf/helpers": "^7.2.0",
    "axios": "^1.9.0",
    "expo": "~53.0.9",
    "expo-build-properties": "~0.14.6",
    "expo-camera": "^16.1.6",
    "expo-constants": "^17.1.6",
    "expo-device": "^7.1.4",
    "expo-font": "^13.3.1",
    "expo-image": "^2.1.7",
    "expo-linking": "^7.1.5",
    "expo-location": "^18.1.5",
    "expo-notifications": "^0.31.2",
    "expo-router": "~5.0.7",
    "expo-secure-store": "^14.2.3",
    "expo-splash-screen": "~0.30.8",
    "expo-status-bar": "~2.2.3",
    "expo-system-ui": "^5.0.7",
    "nativewind": "^4.1.23",
    "react": "19.0.0",
    "react-native": "0.79.2",
    "react-native-gesture-handler": "~2.24.0",
    "react-native-maps": "1.20.1",
    "react-native-reanimated": "~3.17.4",
    "react-native-safe-area-context": "5.4.0",
    "react-native-screens": "~4.10.0",
    "react-native-svg": "15.11.2",
    "react-native-toast-message": "^2.3.0",
    "tailwindcss": "^3.4.15",
    "zod": "^3.25.42",
    "zustand": "^5.0.5"
  },

MariuzM avatar Jun 05 '25 12:06 MariuzM

You are talking about virtual device. So, I believe you have the same problem then.

tomislavkrnic avatar Jun 05 '25 13:06 tomislavkrnic

You are talking about virtual device. So, I believe you have the same problem then.

Does it work for you on virtual device?

MariuzM avatar Jun 05 '25 13:06 MariuzM

I managed to make it work. After hours of analysis, I found out that the problem is not with Mapbox but with expo-core-modules. I use “@rnmapbox/maps”: “10.1.39” with Expo 53.0.10 and the Mapbox SDK 10. Everything works now. The Expo issue for this is this: https://github.com/expo/expo/issues/37250. And this is the working patch: https://github.com/expo/expo/issues/37250#issuecomment-2945783460

LukasB-DEV avatar Jun 06 '25 05:06 LukasB-DEV

For me it is still not working on a fresh project. I am not using either expo-modules nor expo-crypto. This is what I did step-by-step:

  1. Initialise new expo project: npx create-expo-app@latest

  2. cd to project cd my-app

  3. Add mapbox yarn add @rnmapbox/maps

  4. Configure mapbox by adding this line in app.json in plugins array: [ "@rnmapbox/maps", { "RNMapboxMapsDownloadToken": "sk....." } ],

  5. prebuild android: npx expo prebuild --platform android

  6. run android: npx expo run:android

  7. Crashes with the same error

full package.json:

{
  "name": "my-app",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "lint": "expo lint"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.1.0",
    "@react-navigation/bottom-tabs": "^7.3.10",
    "@react-navigation/elements": "^2.3.8",
    "@react-navigation/native": "^7.1.6",
    "@rnmapbox/maps": "^10.1.39",
    "expo": "~53.0.10",
    "expo-blur": "~14.1.5",
    "expo-constants": "~17.1.6",
    "expo-font": "~13.3.1",
    "expo-haptics": "~14.1.4",
    "expo-image": "~2.2.0",
    "expo-linking": "~7.1.5",
    "expo-router": "~5.0.7",
    "expo-splash-screen": "~0.30.9",
    "expo-status-bar": "~2.2.3",
    "expo-symbols": "~0.4.5",
    "expo-system-ui": "~5.0.8",
    "expo-web-browser": "~14.1.6",
    "react": "19.0.0",
    "react-dom": "19.0.0",
    "react-native": "0.79.3",
    "react-native-gesture-handler": "~2.24.0",
    "react-native-reanimated": "~3.17.4",
    "react-native-safe-area-context": "5.4.0",
    "react-native-screens": "~4.11.1",
    "react-native-web": "~0.20.0",
    "react-native-webview": "13.13.5"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@types/react": "~19.0.10",
    "eslint": "^9.25.0",
    "eslint-config-expo": "~9.2.0",
    "typescript": "~5.8.3"
  },
  "private": true,
  "packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
}

Full app.json:

{
  "expo": {
    "name": "my-app",
    "slug": "my-app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "myapp",
    "userInterfaceStyle": "automatic",
    "newArchEnabled": true,
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "edgeToEdgeEnabled": true,
      "package": "com.luka_cityx.myapp"
    },
    "web": {
      "bundler": "metro",
      "output": "static",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": [
      "expo-router",
      [
        "expo-splash-screen",
        {
          "image": "./assets/images/splash-icon.png",
          "imageWidth": 200,
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        }
      ],
      [
        "@rnmapbox/maps",
        {
          "RNMapboxMapsDownloadToken": "sk...."
        }
      ]
    ],
    "experiments": {
      "typedRoutes": true
    }
  }
}

Tried also with: "RNMapboxMapsVersion": "11.12.1" in app.json but no luck

LukakHR avatar Jun 06 '25 09:06 LukakHR

For me it is still not working on a fresh project. I am not using either expo-modules nor expo-crypto. This is what I did step-by-step:

  1. Initialise new expo project: npx create-expo-app@latest
  2. cd to project cd my-app
  3. Add mapbox yarn add @rnmapbox/maps
  4. Configure mapbox by adding this line in app.json in plugins array: [ "@rnmapbox/maps", { "RNMapboxMapsDownloadToken": "sk....." } ],
  5. prebuild android: npx expo prebuild --platform android
  6. run android: npx expo run:android
  7. Crashes with the same error

full package.json:

{ "name": "my-app", "main": "expo-router/entry", "version": "1.0.0", "scripts": { "start": "expo start", "reset-project": "node ./scripts/reset-project.js", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", "lint": "expo lint" }, "dependencies": { "@expo/vector-icons": "^14.1.0", "@react-navigation/bottom-tabs": "^7.3.10", "@react-navigation/elements": "^2.3.8", "@react-navigation/native": "^7.1.6", "@rnmapbox/maps": "^10.1.39", "expo": "~53.0.10", "expo-blur": "~14.1.5", "expo-constants": "~17.1.6", "expo-font": "~13.3.1", "expo-haptics": "~14.1.4", "expo-image": "~2.2.0", "expo-linking": "~7.1.5", "expo-router": "~5.0.7", "expo-splash-screen": "~0.30.9", "expo-status-bar": "~2.2.3", "expo-symbols": "~0.4.5", "expo-system-ui": "~5.0.8", "expo-web-browser": "~14.1.6", "react": "19.0.0", "react-dom": "19.0.0", "react-native": "0.79.3", "react-native-gesture-handler": "~2.24.0", "react-native-reanimated": "~3.17.4", "react-native-safe-area-context": "5.4.0", "react-native-screens": "~4.11.1", "react-native-web": "~0.20.0", "react-native-webview": "13.13.5" }, "devDependencies": { "@babel/core": "^7.25.2", "@types/react": "~19.0.10", "eslint": "^9.25.0", "eslint-config-expo": "~9.2.0", "typescript": "~5.8.3" }, "private": true, "packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447" } Full app.json:

{ "expo": { "name": "my-app", "slug": "my-app", "version": "1.0.0", "orientation": "portrait", "icon": "./assets/images/icon.png", "scheme": "myapp", "userInterfaceStyle": "automatic", "newArchEnabled": true, "ios": { "supportsTablet": true }, "android": { "adaptiveIcon": { "foregroundImage": "./assets/images/adaptive-icon.png", "backgroundColor": "#ffffff" }, "edgeToEdgeEnabled": true, "package": "com.luka_cityx.myapp" }, "web": { "bundler": "metro", "output": "static", "favicon": "./assets/images/favicon.png" }, "plugins": [ "expo-router", [ "expo-splash-screen", { "image": "./assets/images/splash-icon.png", "imageWidth": 200, "resizeMode": "contain", "backgroundColor": "#ffffff" } ], [ "@rnmapbox/maps", { "RNMapboxMapsDownloadToken": "sk...." } ] ], "experiments": { "typedRoutes": true } } } Tried also with: "RNMapboxMapsVersion": "11.12.1" in app.json but no luck

as i know expo-modules-core is part of expo and is also shipped with expo. Please check if you have a expo-modules-core within node_modules

LukasB-DEV avatar Jun 06 '25 09:06 LukasB-DEV

Mapbox SDK 10

https://github.com/rnmapbox/maps/issues/3853#issuecomment-2948187931

To confirm @LukasB-DEV , you're using RNMapboxMapsVersion: "10", and not, say, 11.12.1? I just tried this patch with the latter and did not have success.

RyanTG avatar Jun 06 '25 20:06 RyanTG

Mapbox SDK 10

https://github.com/rnmapbox/maps/issues/3853#issuecomment-2948187931

To confirm @LukasB-DEV , you're using RNMapboxMapsVersion: "10", and not, say, 11.12.1? I just tried this patch with the latter and did not have success.

I use the default SDK 10.18.4 with the newest expo, rnmapbox and react native without issues after the patch for expo-modules-core.

LukasB-DEV avatar Jun 06 '25 20:06 LukasB-DEV

Thanks for confirming. I still get a crash on production with that setup. Last time I looked at adb logcat the only error I could see was about reanimated. But I'm not quite skilled enough to parse it.

RyanTG avatar Jun 06 '25 22:06 RyanTG

Thanks for confirming. I still get a crash on production with that setup. Last time I looked at adb logcat the only error I could see was about reanimated. But I'm not quite skilled enough to parse it.

Have you checked your reanimated version? I also use reanimated: "react-native-reanimated": "~3.17.4

LukasB-DEV avatar Jun 07 '25 05:06 LukasB-DEV

Strange: for my Device with API 34 (Android14) it works. But I get info from user with API 32 (Android 12) that the app crashs at the start. API 30 seems to also work... @RyanTG what Android version are you using for Test? @LukakHR have you found the cause?

LukasB-DEV avatar Jun 10 '25 07:06 LukasB-DEV

That’s interesting. Yes, my test device is Android 12.

My test users I talked to were not reporting issues previously - I will confirm what they’re on (and edit this comment), but fairly sure android 14 because they have new devices. Note that they all started reported crashes to me once I applied that expo-modules-core patch. But prior to that they were fine.

And I’m on that same reanimated.

RyanTG avatar Jun 10 '25 13:06 RyanTG

That’s interesting. Yes, my test device is Android 12.

My test users I talked to were not reporting issues previously - I will confirm what they’re on (and edit this comment), but fairly sure android 14 because they have new devices. Note that they all started reported crashes to me once I applied that expo-modules-core patch. But prior to that they were fine.

And I’m on that same reanimated.

note that the patch is no longer needed - update expo to the newest version and it is fixed

LukasB-DEV avatar Jun 10 '25 14:06 LukasB-DEV

I have now finally got it running on all devices. RN Switched to the new Metro ES Module resolution in Expo 53 and RN 79. This causes this error and crash in the release build for Android:

[runtime not ready]: ReferenceError: Property 'require' doesn't exist, js engine: hermes

There is this expo discussion: https://github.com/expo/expo/discussions/36551

With config.resolver.unstable_enablePackageExports = false; it now works for me.

Important: presets: ['babel-preset-expo'] must be set in babel.config.js - otherwise the workaround will not work.

LukasB-DEV avatar Jun 10 '25 15:06 LukasB-DEV

I was hopeful, but alas it didn't resolve my issue with Android 12. Android 13+ is fine.

We are using sentry, so our metro looks a little different. Not sure if that is a problem.

//metro.config.js
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
config.resolver.unstable_enablePackageExports = false;
module.exports = config;

//babel.config.js
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: ["inline-dotenv", "react-native-reanimated/plugin"],
  };
};

Here is my adb logcat of a launch and crash. https://gist.github.com/RyanTG/10bfaf68119a1c4a98887bb600a79144

It doesn't match up with what's in that issue, so it seems like I'm experiencing something different. But I can't tell what. Despite the mentions of "bridge" I have trouble believing this is related to New Architecture, given that we switched to it in SDK 52 with no problems.

RyanTG avatar Jun 11 '25 04:06 RyanTG

I was hopeful, but alas it didn't resolve my issue with Android 12. Android 13+ is fine.

We are using sentry, so our metro looks a little different. Not sure if that is a problem.

//metro.config.js
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname);
config.resolver.unstable_enablePackageExports = false;
module.exports = config;

//babel.config.js
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: ["inline-dotenv", "react-native-reanimated/plugin"],
  };
};

Here is my adb logcat of a launch and crash. https://gist.github.com/RyanTG/10bfaf68119a1c4a98887bb600a79144

It doesn't match up with what's in that issue, so it seems like I'm experiencing something different. But I can't tell what. Despite the mentions of "bridge" I have trouble believing this is related to New Architecture, given that we switched to it in SDK 52 with no problems.

Yes seems that you hab another issue. Have you tried to run npx expo install --fix

LukasB-DEV avatar Jun 11 '25 04:06 LukasB-DEV

Have you tried to run npx expo install --fix

Yes, I run that regularly. We're still using react-navigation 6 (just throwing out another random data point). This whole thing is puzzling. I still think it's notable that others are experiencing the same outcome (crashing in prod on Android 12 and not on later Android versions).

RyanTG avatar Jun 11 '25 05:06 RyanTG

Another guess: https://github.com/facebook/react-native/issues/51628

My testing device is 32-bit. I don't know much about TurboModules, but there certainly are a number of packages using NativeEventEmitter

RyanTG avatar Jun 12 '25 04:06 RyanTG