Skip to content

Conversation

efstathiosntonas
Copy link

@efstathiosntonas efstathiosntonas commented Jun 11, 2025

Description

Fixes on Android:

 WARN  new NativeEventEmitter() was called with a non-null argument without the required addListener method.
 WARN  new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

introduced in this PR: #3789

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android
    • In New Architecture mode/android
  • I added/updated a sample - if a new feature was implemented (/example)

@efstathiosntonas
Copy link
Author

patch:

@rnmapbox+maps+10.1.39.patch

diff --git a/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt b/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
index 7c87fc2..5d78df7 100644
--- a/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
+++ b/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
@@ -132,12 +132,12 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
     }
 
     @ReactMethod
-    fun addListener(eventName: String?) {
+    override fun addListener(eventName: String?) {
         // Required for rn built in EventEmitter Calls.
     }
 
     @ReactMethod
-    fun removeListeners(count: Int?) {
+    override fun removeListeners(count: Int?) {
         // Required for rn built in EventEmitter Calls.
     }
 
diff --git a/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java b/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
index e5db5cb..cf854f7 100644
--- a/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
+++ b/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
@@ -65,4 +65,12 @@ public abstract class NativeRNMBXLocationModuleSpec extends ReactContextBaseJava
   @ReactMethod
   @DoNotStrip
   public abstract void setLocationEventThrottle(double throttle);
+
+  @ReactMethod
+  @DoNotStrip
+  public abstract void addListener(String eventName);
+
+  @ReactMethod
+  @DoNotStrip
+  public abstract void removeListeners(Integer count);
 }

@javier-sauma-rocketlab
Copy link

Nice one, Hopefully someone take a look on this

@DavidAmyot
Copy link

+1

ignaciotcrespo added a commit to umob-developer/rnmapbox that referenced this pull request Jul 1, 2025
ignaciotcrespo added a commit to umob-developer/rnmapbox that referenced this pull request Jul 1, 2025
ignaciotcrespo added a commit to umob-developer/rnmapbox that referenced this pull request Jul 1, 2025
Copy link

@fresnel-bruno fresnel-bruno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand the fix
but looks like it's ok

@efstathiosntonas
Copy link
Author

@fresnel-bruno it’s a common pattern with the event emitters, if you search for the keywords on github you will find out that this is how they are handled on other packages too.

@allthetime
Copy link

patch:

@rnmapbox+maps+10.1.39.patch

diff --git a/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt b/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
index 7c87fc2..5d78df7 100644
--- a/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
+++ b/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt
@@ -132,12 +132,12 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
     }
 
     @ReactMethod
-    fun addListener(eventName: String?) {
+    override fun addListener(eventName: String?) {
         // Required for rn built in EventEmitter Calls.
     }
 
     @ReactMethod
-    fun removeListeners(count: Int?) {
+    override fun removeListeners(count: Int?) {
         // Required for rn built in EventEmitter Calls.
     }
 
diff --git a/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java b/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
index e5db5cb..cf854f7 100644
--- a/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
+++ b/node_modules/@rnmapbox/maps/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java
@@ -65,4 +65,12 @@ public abstract class NativeRNMBXLocationModuleSpec extends ReactContextBaseJava
   @ReactMethod
   @DoNotStrip
   public abstract void setLocationEventThrottle(double throttle);
+
+  @ReactMethod
+  @DoNotStrip
+  public abstract void addListener(String eventName);
+
+  @ReactMethod
+  @DoNotStrip
+  public abstract void removeListeners(Integer count);
 }

Using this patch gives compilation error

/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:140:5 'removeListeners' overrides nothing. FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.

@efstathiosntonas
Copy link
Author

@allthetime which react-native version? fabric or paper?

@mfazekas
Copy link
Contributor

mfazekas commented Aug 8, 2025

@efstathiosntonas thanks much for the PR, looks good to me

Can you please rebase, so CI can run?
Also can you add instruction on how to reproduce the issue?

@efstathiosntonas
Copy link
Author

Hi @mfazekas, will rebase in a while.

Just booting the app showed the warnings in the console, nothing special.

g4rb4g3 and others added 8 commits August 8, 2025 12:46
* [android] add easeTo, moveBy and scaleBy using screen coordinates

* cleanup

* [ios] add easeTo, moveBy and scaleBy using screen coordinates

* update docs

* align ios camera animation mode to androids numeric values

* fix: nonnull error on ios

* final adjustments

* fix missing nonnull

* rm easeTo

* update docs
…nmapbox#3908)

* up mapbox to 11.13.4

* update lockfiles, update @types/react

* update generated and update node to node 22
…cation (rnmapbox#3838)

* fix(android): prevent crash in old architecture when updating user location

* fix(android): move update location callback from auto generated code

* Update android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt

---------

Co-authored-by: Miklós Fazekas <mfazekas@szemafor.com>
…nmapbox#3890)

This bug appears using the new react architecture.
This is because of the id allowOverlap = RNMBXConvertFollyDynamicToId(newProps.allowOverlap); conversions that returns a pointer that is always true instead of the value of the pointed object according to rnmapbox#3730
* fix(android): ignore camera padding for marker view

* fix(android): mapbox 10 build error (due to cameraIgnorePadding option)
* feat: Upgrade example project to React Native 0.80.2

## Changes

### Dependencies
- Upgrade React Native from 0.79.1 to 0.80.2
- Upgrade React from 19.0.0 to 19.1.0 (required for RN 0.80)
- Upgrade React Native CLI to 19.0.0
- Upgrade all @react-native/* packages to 0.80.2
- Upgrade react-native-screens to 4.13.1 for RN 0.80 compatibility

### Android
- Update Kotlin version to 2.1.20 (RN 0.80 recommended)
- Update Gradle to 8.14.1
- Fix nullability issues in 20+ Kotlin files for stricter type checking
- Update MainApplication.kt to use loadReactNative() instead of SoLoader
- Add proper null checks with error logging throughout codebase

### iOS
- Enable bridgeless mode in AppDelegate.mm
- Update iOS pods for RN 0.80 compatibility

### Configuration
- Update metro.config.js (blacklistRE → blockList)
- Enable New Architecture (newArchEnabled=true)
- Enable Hermes (hermesEnabled=true)

Fixes rnmapbox#3915

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* pnpm -> yarn

* run generate

* fix: Use correct gradle-wrapper.jar from RN 0.80.2 template

* fix(android): Handle nullable sourceLayerID in RNMBXModelLayer for Kotlin 2.1.20 compatibility

* fix: Revert pnpm references back to yarn

---------

Co-authored-by: Claude <noreply@anthropic.com>
@efstathiosntonas
Copy link
Author

efstathiosntonas commented Aug 8, 2025

@mfazekas just rebased

to add some context on the previous comment about reproducing, I use rn@0.79.5 on Paper

@mcastets
Copy link

mcastets commented Aug 13, 2025

Using this patch gives compilation error

/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:140:5 'removeListeners' overrides nothing. FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.

Experiencing this too, main difference is that I'm on fabric (RN 0.79).

[RUN_GRADLEW] e: file:///private/var/folders/ch/719g3dfj2mz6cwrnzcx6mg500000gp/T/eas-build-local-nodejs/f77ff0f1-b5a2-4a65-b59b-5a3bbd982a6a/build/fronts/app-mobile/ui/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:19:1 Class 'RNMBXLocationModule' is not abstract and does not implement abstract base class member 'removeListeners'.                                                 
[RUN_GRADLEW] e: file:///private/var/folders/ch/719g3dfj2mz6cwrnzcx6mg500000gp/T/eas-build-local-nodejs/f77ff0f1-b5a2-4a65-b59b-5a3bbd982a6a/build/fronts/app-mobile/ui/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:142:5 'removeListeners' overrides nothing.    

@regalstreak
Copy link

Any updates here? @efstathiosntonas @mcastets

Also facing the compilation error

@mcastets
Copy link

mcastets commented Sep 1, 2025

Any updates here? @efstathiosntonas @mcastets

Also facing the compilation error

I haven't applied the patch and I just live with the original warning. I don't think it's harmful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.