maps
maps copied to clipboard
[Bug]: Build failed cannot find symbol mEventEmitterCallback.invoke("onLocationUpdate", value);
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
Having the same issue here...
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.
Having same issue.
"react-native": "0.71.4", "expo": "^48.0.17", "@rnmapbox/maps": "^10.1.37",
Having the same issue here
having the same issue
"react-native": "0.75.5", "@rnmapbox/maps": "^10.1.37"
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"
Had the same problem. Recovered an older version @rnmapbox/[email protected] and the problem had gone.
It works with v10.1.36, which is only one version downgrade from the latest one.
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.
same issue than @apbarratt here, upgrading from 10.1.33 to 10.1.37, can not upgrade to latest version
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?
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
Ok, after some research I've found the following:
- rnmapbox
v10.1.37depends on react native0.76.x - in RN
0.76.xnew architecture is enabled by default - the field
mEventEmitterCallbackwas added to RN0.76.xin 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
mEventEmitterCallbackpresent only in RN0.76.x - the class using TurboModules is included in the rnmapbox android sources only when
isNewArchitecture=falseingradle.properties
In short:
- rnmapbox
v10.1.37supports 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
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
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",
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
@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} />
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)
This should be addressed by recent versions