VideoUIKit-ReactNative icon indicating copy to clipboard operation
VideoUIKit-ReactNative copied to clipboard

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

Open rockzy77 opened this issue 2 years ago • 4 comments

Target device:

  • Device: Realme 9
  • OS:
    • Android
  • OS Version: Android 11

App Info

  • Type:
    • React Native CLI
  • CLI Version: 0.71.4

I copy pasted the code from docs and tried debugging the app in my physical device. But when the app is loaded its showing the error

 `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
    at StackNavigation (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:95453:41)
    at ProfileProvider (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:107897:36)
    at App
    at RCTView
    at View (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45928:43)
    at RCTView
    at View (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45928:43)
    at AppContainer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45809:36)
    at HospitalApp(RootComponent) (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:83815:28)
 WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
    at StackNavigation (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:95453:41)
    at ProfileProvider (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:107897:36)
    at App
    at RCTView
    at View (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45928:43)
    at RCTView
    at View (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45928:43)
    at AppContainer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:45809:36)
    at HospitalApp(RootComponent) (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.liveopd.healthcare&modulesOnly=false&runModule=true:83815:28)

No specific config was mentioned in the documents. What should I do? Why this is occuring?

This is my dependencies in packages.json

"dependencies": {
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-native-community/datetimepicker": "^6.7.5",
    "@react-native-firebase/app": "^17.3.2",
    "@react-native-firebase/auth": "^17.3.2",
    "@react-native-google-signin/google-signin": "^9.0.2",
    "@react-native-picker/picker": "^2.4.9",
    "@react-navigation/bottom-tabs": "^6.5.7",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "agora-react-native-rtm": "^1.5.1",
    "agora-rn-uikit": "^5.0.1",
    "axios": "^1.3.4",
    "react": "18.2.0",
    "react-native": "0.71.4",
    "react-native-agora": "^4.1.2",
    "react-native-datepicker": "^1.7.2",
    "react-native-document-picker": "^8.1.3",
    "react-native-element-dropdown": "^2.8.1",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-image-crop-picker": "^0.39.0",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-reanimated": "^2.14.4",
    "react-native-redash": "^18.1.0",
    "react-native-safe-area-context": "^4.5.0",
    "react-native-screens": "^3.20.0",
    "react-native-select-dropdown": "^3.3.0",
    "react-native-translation": "^1.1.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-web": "^0.18.12"
  },

This is the video call code

import React, {useState} from 'react';
import AgoraUIKit from 'agora-rn-uikit';
import { useRoute } from '@react-navigation/native';

export const VideoCall = () => {
  const [videoCall, setVideoCall] = useState(true);
  const {appId, channelName} = useRoute().params;
  const connectionData = {
    appId: appId,
    channel: channelName,
  };
  const rtcCallbacks = {
    EndCall: () => {
      setVideoCall(false);
      nav(-1);
    },
  };
  return videoCall ? (
    <AgoraUIKit connectionData={connectionData} rtcCallbacks={rtcCallbacks} />
  ) : (
    <Text onPress={()=>setVideoCall(true)}>Start Call</Text>
  );
};

rockzy77 avatar May 09 '23 06:05 rockzy77

Can you please tell me how you solved this problem? I'm stuck

gulshan-4 avatar Sep 23 '23 12:09 gulshan-4

Does this warning make the app unusable? Can you try dismissing it to see if everything else works?

EkaanshArora avatar Sep 23 '23 15:09 EkaanshArora

@EkaanshArora App just crashes, here's my log:

 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.
 ERROR  Your app just crashed. See the error below.
java.lang.RuntimeException: Unable to resume activity {com.petinder/com.petinder.MainActivity}: java.lang.reflect.InvocationTargetException     
  android.app.ActivityThread.performResumeActivity(ActivityThread.java:4961)
  android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4994)
  android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
  android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
  android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180)
  android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
  android.os.Handler.dispatchMessage(Handler.java:106)
  android.os.Looper.loopOnce(Looper.java:205)
  android.os.Looper.loop(Looper.java:294)
  android.app.ActivityThread.main(ActivityThread.java:8176)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by java.lang.reflect.InvocationTargetException
  java.lang.reflect.Method.invoke(Native Method)
  expo.modules.ReactActivityDelegateWrapper.invokeDelegateMethod(ReactActivityDelegateWrapper.kt:285)
  expo.modules.ReactActivityDelegateWrapper.onResume(ReactActivityDelegateWrapper.kt:163)
  com.facebook.react.ReactActivity.onResume(ReactActivity.java:58)
  android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1603)
  android.app.Activity.performResume(Activity.java:8743)
  android.app.ActivityThread.performResumeActivity(ActivityThread.java:4951)
  android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4994)
  android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
  android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
  android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180)
  android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
  android.os.Handler.dispatchMessage(Handler.java:106)
  android.os.Looper.loopOnce(Looper.java:205)
  android.os.Looper.loop(Looper.java:294)
  android.app.ActivityThread.main(ActivityThread.java:8176)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Callback.invoke(java.lang.Object[])' on a null object reference
  com.facebook.react.modules.permissions.PermissionsModule.onRequestPermissionsResult(PermissionsModule.java:201)
  com.facebook.react.ReactActivityDelegate$2.invoke(ReactActivityDelegate.java:201)
  com.facebook.react.ReactActivityDelegate.onResume(ReactActivityDelegate.java:126)
  java.lang.reflect.Method.invoke(Native Method)
  expo.modules.ReactActivityDelegateWrapper.invokeDelegateMethod(ReactActivityDelegateWrapper.kt:285)
  expo.modules.ReactActivityDelegateWrapper.onResume(ReactActivityDelegateWrapper.kt:163)
  com.facebook.react.ReactActivity.onResume(ReactActivity.java:58)
  android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1603)
  android.app.Activity.performResume(Activity.java:8743)
  android.app.ActivityThread.performResumeActivity(ActivityThread.java:4951)
  android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4994)
  android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
  android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
  android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180)
  android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
  android.os.Handler.dispatchMessage(Handler.java:106)
  android.os.Looper.loopOnce(Looper.java:205)
  android.os.Looper.loop(Looper.java:294)
  android.app.ActivityThread.main(ActivityThread.java:8176)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

gulshan-4 avatar Sep 25 '23 04:09 gulshan-4

i'm also stuck with this error i have applied code which is mention in docs with fresh project Errors -> new NativeEventEmitter() was called with a non-null argument without the required addListener method. new NativeEventEmitter() was called with a non-null argument without the required removeListeners method.

Installed Dependencies -> "agora-react-native-rtm": "^1.5.1", "agora-rn-uikit": "^5.0.1", "react": "18.2.0", "react-native": "0.72.4", "react-native-agora": "^4.2.1",

import AgoraUIKit from 'agora-rn-uikit';

const App = () => { const [videocall, setVideocall] = useState(true);

const connectionData = { appId: '83083d0a42961ead****', channel: 'test', };

const rtcCallbacks = { EndCall: () => setVideocall(false), };

return videocall ? ( <AgoraUIKit connectionData={connectionData} rtcCallbacks={rtcCallbacks} /> ) : ( <Text onPress={() => setVideocall(true)}>Start Call</Text> ); export default App;

Abhaychovatiya avatar Oct 02 '23 09:10 Abhaychovatiya