fix: new NativeEventEmitter() was called with a non-null argument
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: https://github.com/rnmapbox/maps/pull/3789
Checklist
- [x] I've read
CONTRIBUTING.md - [ ] I updated the doc/other generated code with running
yarn generatein the root folder - [ ] I have tested the new feature on
/exampleapp.- [ ] 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)
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);
}
Nice one, Hopefully someone take a look on this
+1
@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.
patch:
@rnmapbox+maps+10.1.39.patchdiff --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'.
@allthetime which react-native version? fabric or paper?
@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?
Hi @mfazekas, will rebase in a while.
Just booting the app showed the warnings in the console, nothing special.
@mfazekas just rebased
to add some context on the previous comment about reproducing, I use [email protected] on Paper
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.
Any updates here? @efstathiosntonas @mcastets
Also facing the compilation error
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.
@efstathiosntonas I think most of this PR is already merged?
@mfazekas I think so yeah, feel free to close it