Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant Violation: new NativeEventEmitter() requires a non-null argument. #346

Open
nachoSource opened this issue May 26, 2022 · 18 comments
Labels
bug Something isn't working

Comments

@nachoSource
Copy link

nachoSource commented May 26, 2022

Environment

System:
OS: macOS 12.4
CPU: (8) x64 Apple M1
Memory: 24.48 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: Not Found
npm: 8.1.2 - /usr/local/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
Languages:
Java: 18.0.1.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

This is only happening in iOS (I am working with the xCode simulator). In Android devices it works fine.

Versions

Please add the used versions/branches

  • iOS: 15.0
  • react-native-geolocation-service: master & ios-rewrite
  • react-native: 0.68.2

Description

Please provide a clear and concise description of what the bug is. Include screenshots if needed.

Reproducible Demo

Provide a detailed list of steps that reproduce the issue.

  1. Install a new app following the [RN doc](Invariant Violation: new NativeEventEmitter() requires a non-null argument.) and the instructions required in this library's readme files.
  2. Run cd ios && pod install
  3. Run either npm run ios or use the xCode interface (the error is the same)

Expected Results

The app runs properly as it does in Android devices

Here is the complete error log:

image

@nachoSource nachoSource added the bug Something isn't working label May 26, 2022
@nachoSource
Copy link
Author

nachoSource commented May 26, 2022

Here I attach some screenshots taken from my simulator.
I've also read that the second error usually disappears when the first one is solved, but I show it just in case.
image
image

@nachoSource
Copy link
Author

Apparently, this import has some kind of issue 🤔
https://user-images.githubusercontent.com/69126302/170710377-4c39ab83-09c5-4e07-b7b1-f93d7b11f2c6.mov

@dgasch512
Copy link

I was getting this until I ran cd ios/ && pod install after installing the package. Could be a pod issue?

@Agontuk
Copy link
Owner

Agontuk commented Jun 17, 2022

pod install is required and it's already described in the setup docs.

@k-saparia
Copy link

k-saparia commented Aug 23, 2022

This issue still persists.... on development is all good. However, when I run yarn test, I get this error!! Current Version is 5.3.0

@mwmcode
Copy link

mwmcode commented Aug 26, 2022

Happens when I run appium (e2e tests). It fails to load the app bundle (when in dev mode, loads release bundles fine) onto iOS emulator. After some debugging, it turned out that that error is thrown whenever some packages are present:

  • react-native-device-info
  • @react-native-firebase/messaging

The (hacky) workaround I have is to dynamically/conditionally import() such packages when NOT running in E2E mode (env var)

export let requestUserPermission = ( _user: User) => ({});

if (!Env.IS_E2E_MODE) {
  (async function loadFirebaseMessaging() {
    const { default: messaging } = await import(
      '@react-native-firebase/messaging'
    );
    requestUserPermission = async (user: User) => {
      const authStatus = await messaging().requestPermission();
      // ....etc
    }
   })();
}

@erickcrus
Copy link

same issue

@divyanshGarg96
Copy link

I am facing the same issue. Has someone found the solution to this ?

@kimcccheung
Copy link

I face the same issue. Any solutions?

@nassim-yagoub
Copy link

nassim-yagoub commented Nov 16, 2022

I faced the same issue on IOS and solved it by adding this line to my podfile:
pod 'react-native-geolocation-service', path: '../node_modules/react-native-geolocation-service'

According to the setup docs it should not be necessary for RN 0.60 or higher but it solved the issue for me with RN 0.65.3.

However I still had the issue when running tests, I solved it by mocking the package, I only needed PositionError so I created a file __mocks__/react-native-geolocation-service.ts in which I put this enum:

export default {};

export enum PositionError {
  PERMISSION_DENIED = 1,
  POSITION_UNAVAILABLE = 2,
  TIMEOUT = 3,
  PLAY_SERVICE_NOT_AVAILABLE = 4,
  SETTINGS_NOT_SATISFIED = 5,
  INTERNAL_ERROR = -1,
}

You can probably mock everything else you need from this package

@lmasneri
Copy link

Same issue there

@gomezmark
Copy link

any updates? have you guys solved this issue?
thank you

@inaieforster
Copy link

same issue :(

@anishsundarjee
Copy link

Adding this fixed it for me.

@MAKARD
Copy link

MAKARD commented Feb 22, 2023

RN 0.70 same here

@AliBaig-xD
Copy link

AliBaig-xD commented Feb 28, 2023

In my case I forgot to run pod install in my app. Other way is to link the library manually in your podfile

@DongDongDongDong
Copy link

I also encountered the same problem, but it was prompted that the module I couldn't find is the NativeKeyboardObserver. I am using version 0.68.

<null Invariant Violation: new NativeEventEmitter() requires a non-null argument.>

Do you guys have a solution

@danieledisons
Copy link

I also have the same issue. Any solution??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests