maps icon indicating copy to clipboard operation
maps copied to clipboard

[Bug]: Build failed cannot find symbol mEventEmitterCallback.invoke("onLocationUpdate", value);

Open dukizwe opened this issue 9 months ago • 17 comments

Mapbox Implementation

Mapbox

Mapbox Version

default

React Native Version

0.72.10

Platform

Android

@rnmapbox/maps version

10.1.8

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

Build failed with this error:

> Task :rnmapbox_maps:compileDebugJavaWithJavac
C:\Users\mbaga\Lab\wisili-rider-app\node_modules\@rnmapbox\maps\android\src\main\old-arch\com\rnmapbox\rnmbx\NativeRNMBXLocationModuleSpec.java:38: error: cannot find symbol
    mEventEmitterCallback.invoke("onLocationUpdate", value);
    ^
  symbol:   variable mEventEmitterCallback
  location: class NativeRNMBXLocationModuleSpec
1 error

Expected behavior

No response

Notes / preliminary analysis

No response

Additional links and references

No response

dukizwe avatar Feb 28 '25 09:02 dukizwe

Having the same issue here...

lucadegasperi avatar Mar 01 '25 12:03 lucadegasperi

Same issue here. Expo sdk 51.0.38 React native 0.74.5 rnmapbox/maps 10.1.31

If I upgrade to expo 52 sdk, and open the app on android, it crashes due to this location error.

vasilring avatar Mar 01 '25 16:03 vasilring

Having same issue.

"react-native": "0.71.4", "expo": "^48.0.17", "@rnmapbox/maps": "^10.1.37",

NidheeshVgopal avatar Mar 03 '25 08:03 NidheeshVgopal

Having the same issue here

ayuleul avatar Mar 04 '25 04:03 ayuleul

having the same issue

"react-native": "0.75.5", "@rnmapbox/maps": "^10.1.37"

hieuminh1810 avatar Mar 04 '25 05:03 hieuminh1810

Here is the temporary Fix ✅

Manually Edit the Package Code

Edit the file:

node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java

Add import

import com.facebook.react.bridge.Callback;

Add private Callback mEventEmitterCallback in class NativeRNMBXLocationModuleSpec

public abstract class NativeRNMBXLocationModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
    private Callback mEventEmitterCallback; // ✅ Correct placement inside class

Edit the emitOnLocationUpdate and add null check for mEventEmitterCallback

protected final void emitOnLocationUpdate(ReadableMap value) {
    if (mEventEmitterCallback != null) {
        mEventEmitterCallback.invoke("onLocationUpdate", value);
    }
  }

Now patch the package for Auto Package update each time you tigger npm i.

npm i patch-package

Run this in root of your project **npx patch-package @rnmapbox/maps**

Add this in your "scripts" in project package.json "postinstall": "patch-package"

Rahul-Ranjan-Singh avatar Mar 04 '25 14:03 Rahul-Ranjan-Singh

Had the same problem. Recovered an older version @rnmapbox/[email protected] and the problem had gone.

zvilif avatar Mar 05 '25 10:03 zvilif

It works with v10.1.36, which is only one version downgrade from the latest one.

ayuleul avatar Mar 05 '25 10:03 ayuleul

Confirming we've also had this same issue in our development after upgrading to latest from 10.1.33 to 10.1.37 on both Android and iOS builds. Rolling back one patch version to 10.1.36 has resolved the problem for us too.

apbarratt avatar Mar 11 '25 16:03 apbarratt

same issue than @apbarratt here, upgrading from 10.1.33 to 10.1.37, can not upgrade to latest version

ignaciotcrespo avatar Mar 18 '25 10:03 ignaciotcrespo

It's a little troubling that we've not heard anything from a contributor on this project given this was reported shortly after the release of 10.1.37 three weeks ago now.

@Rahul-Ranjan-Singh As you seem to have a good understanding of what the issue is, would you feel confident to fork and put together a PR to suggest a fix?

apbarratt avatar Mar 18 '25 11:03 apbarratt

Confirmed, version 10.1.36 works for me (in React Native 0.74.5) @Rahul-Ranjan-Singh , Vote to create a PR to suggest a solution or at least initiate the conversation to give a solution

TheSaulMx avatar Mar 20 '25 22:03 TheSaulMx

Ok, after some research I've found the following:

  • rnmapbox v10.1.37 depends on react native 0.76.x
  • in RN 0.76.x new architecture is enabled by default
  • the field mEventEmitterCallback was added to RN 0.76.x in PR https://github.com/facebook/react-native/pull/44906 to support TurboModules
  • support for TurboModules was added to rnmapbox at PR https://github.com/rnmapbox/maps/pull/3789, using the new field mEventEmitterCallback present only in RN 0.76.x
  • the class using TurboModules is included in the rnmapbox android sources only when isNewArchitecture=false in gradle.properties

In short:

  • rnmapbox v10.1.37 supports only RN >= 0.76.x

using RN < 0.76.x with isNewArchitecture=true in gradle.properties is not an option due to how the changes were implemented at PR https://github.com/rnmapbox/maps/pull/3789 if you want to support older RN versions add the patch described by @Rahul-Ranjan-Singh at https://github.com/rnmapbox/maps/issues/3795#issuecomment-2697844403

ignaciotcrespo avatar Mar 21 '25 02:03 ignaciotcrespo

Having same issue.

"react-native": "0.73.6", "expo": "^50.0.18", "@rnmapbox/maps": "^10.1.33",

tried the following versions for rnmapbox and still facing the issue: ^10.1.33, ^10.1.36, ^10.1.37, ^10.1.38

jamestangeres avatar Apr 11 '25 09:04 jamestangeres

react-native": "0.71.4", "expo": "^48.0.17", "@rnmapbox/maps": "^10.1.37", i changed @rnmapbox/maps from "^10.1.37" to "10.1.31", solved my issue

react-native": "0.71.4", "expo": "^48.0.17", "@rnmapbox/maps": "10.1.31",

NidheeshVgopal avatar Apr 11 '25 09:04 NidheeshVgopal

Having same issue.

"react-native": "0.73.6", "expo": "^50.0.18", "@rnmapbox/maps": "^10.1.33",

tried the following versions for rnmapbox and still facing the issue: ^10.1.33, ^10.1.36, ^10.1.37, ^10.1.38

I'm able to fix using the version 10.1.38 and by following this: https://github.com/rnmapbox/maps/issues/3795#issuecomment-2697844403

jamestangeres avatar Apr 11 '25 14:04 jamestangeres

@ignaciotcrespo adding the patch did fix my build issue but the onUpdate prop of UserLocation does not seem to work in android. I am using "react-native: "0.75.4", "@rnmapbox/maps": "^10.1.37". Everything works fine in ios. This is my UserLocation component. Did anyone else face this issue? Been on this issue all day <MapboxGL.UserLocation visible={false} onUpdate={handleLocationUpdate} showsUserHeadingIndicator={false} />

avinash2407 avatar May 23 '25 14:05 avinash2407

I've been experiencing this issue as well as https://github.com/rnmapbox/maps/issues/3812

Wanted to share my current fix.

I'm using 10.1.36

react-native 76, expo 52

Android location blue dot was not updating when users would move. I'm using this patch to solve the issue (excuse the console logs)

@rnmapbox+maps+10.1.36.patch

fractalscape13 avatar Jul 18 '25 00:07 fractalscape13

This should be addressed by recent versions

mfazekas avatar Sep 22 '25 12:09 mfazekas