maps: [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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 18
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.javaAdd import
import com.facebook.react.bridge.Callback;Add private Callback mEventEmitterCallback in class NativeRNMBXLocationModuleSpec
Edit the emitOnLocationUpdate and add null check for mEventEmitterCallback
Now patch the package for Auto Package update each time you tigger npm i.
npm i patch-packageRun this in root of your project
**npx patch-package @rnmapbox/maps**Add this in your “scripts” in project package.json
"postinstall": "patch-package"It works with
v10.1.36, which is only one version downgrade from the latest one.Ok, after some research I’ve found the following:
v10.1.37depends on react native0.76.x0.76.xnew architecture is enabled by defaultmEventEmitterCallbackwas added to RN0.76.xin PR https://github.com/facebook/react-native/pull/44906 to support TurboModulesmEventEmitterCallbackpresent only in RN0.76.xisNewArchitecture=falseingradle.propertiesIn short:
v10.1.37supports only RN >=0.76.xusing RN <
0.76.xwithisNewArchitecture=trueingradle.propertiesis 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-2697844403Confirming we’ve also had this same issue in our development after upgrading to latest from
10.1.33to10.1.37on both Android and iOS builds. Rolling back one patch version to10.1.36has resolved the problem for us too.I’m able to fix using the version 10.1.38 and by following this: 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