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. #6

Closed
1 of 5 tasks
Dallas62 opened this issue Nov 8, 2021 · 15 comments · Fixed by #18
Closed
1 of 5 tasks

Comments

@Dallas62
Copy link

Dallas62 commented Nov 8, 2021

HI,

I was testing this application and I fall into this issue.

PR coming soon.

Issue

After installing the main branch, I compile the library on iOS, everything was fine expected that the application is not starting due to:

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

Project Files

No specific project file required.


Environment

Click To Expand

react-native info output:

System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 6.09 GB / 64.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.1 - /usr/local/bin/node
    Yarn: 1.12.3 - ~/.npm-packages/bin/yarn
    npm: 7.18.1 - ~/.npm-packages/bin/npm
    Watchman: 2021.11.01.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
      Build Tools: 23.0.1, 24.0.2, 25.0.0, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.0, 28.0.2, 28.0.3, 29.0.2, 30.0.2, 30.0.3
      System Images: android-16 | Google APIs Intel x86 Atom, android-18 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-21 | Google APIs ARM EABI v7a, android-21 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs ARM EABI v7a, android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_131 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^17.0.1 => 17.0.2 
    react-native: ^0.66 => 0.66.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • Are you using TypeScript?
    • N

@Dallas62 Dallas62 added the help wanted Extra attention is needed label Nov 8, 2021
@Dallas62
Copy link
Author

Dallas62 commented Nov 8, 2021

This will probably not help you so much, but there is a module prefixed with RN (iOS) and Android doesn't seems to be prefixed.
I investigate a bit to make the module load, but the state of the repository seems to be not ready (variable undeclared, ...).
Some changes I was forced to make "start" until TypeError: undefined is not a function on Module.native.

Here the changes:
Dallas62@a85abd2

@mikehardy
Copy link
Collaborator

It is not ready yet, many apologies @Dallas62 and 👋 by the way :-)
Still a work in progress but it will live again after extraction from react-native-firebase 🧟

@ShivamJoker
Copy link

@mikehardy do we have a release date ?
There doesn't seem to be any other react native libraries for admob that works perfectly

@mikehardy
Copy link
Collaborator

Sorry, giving release dates in open source is just a recipe for pain and disappointment
All I can say is that it is a high priority, and I'm sorry it's taken as long as it has to this point!

@mikehardy
Copy link
Collaborator

@dylancom has got a native banner rendering again with some small tweaks, we may have a usable main branch in just a moment! then it is off to the races.... 🏎️

@Dallas62
Copy link
Author

Dallas62 commented Dec 7, 2021

Thanks for your efforts, I switched temporary to https://github.com/react-native-admob/admob to avoid an issue with iOS in the old rnfirebase-admob version.

@mikehardy
Copy link
Collaborator

Keep an eye out - there's a 1.0.0 release coming shortly, courtesy entirely of @dylancom - is this the one you mention @Dallas62 ? #5 - or is it not logged (yet)?

@ShivamJoker
Copy link

ShivamJoker commented Dec 9, 2021

@mikehardy I am getting this error in dev and the app is crashing in release build on android immediately
Here are the codes if you want to have a look - https://github.com/ShivamJoker/SQL-Play/tree/fix/invertase-admob

@mikehardy
Copy link
Collaborator

@ShivamJoker thank you for testing! As part of the initial release to npm I had a lot of work to do getting the files section in package.json correct and .npmignore files set up etc etc, and I made an error in that. v1.0.2 went out this morning and should fix the "crash immediately" issue - the problem was that the configuration machinery depends on react-native-config.js existing (to tell react-native to run our config scripts...) and it was typo'd by me in the files list so simply wasn't included at all.

Please let me know how v1.0.2 goes, hopefully a lot more positive, @dylancom asserts it's working for him

@ShivamJoker
Copy link

@mikehardy now it seems to be working fine but the native event emitter issue is still now gone in dev version.
Thanks for the great work

@mikehardy
Copy link
Collaborator

Thanks for testing!
To get rid of the new NativeEventemitter() requires a non-null argument warning/error in dev iOS needs to implement the required methods, carefully calling super methods and managing observer state etc. If Android also implements them (and arguably, it should) then it also needs to manage listener count status and not emit events if there are no listeners.

Solution sketch and more details on a related module here: react-native-netinfo/react-native-netinfo#486 (comment)

I'll peel this comment to a new issue to keep it alive and contain all the info I documented above

@mikehardy
Copy link
Collaborator

Just to note since I know there are some very interested parties here that have history of making PRs, testing things etc: I've got fully automated releases working here, we can merge PRs really quickly and get your work out if you propose anything. Additionally I don't have it working quite yet (#28 ) but PRs should automatically generate a patch-package set for every push also, making for a closed loop of testing without me (person who hits release button) even needing to do anything, so no waiting around. All this is geared towards velocity and making contributing enjoyable. So if you were thinking about it but haven't, give it a shot as soon as as v8 is done (since I know it's in progress this moment...)

@mikehardy
Copy link
Collaborator

@dylancom has done the port to ios v8! And we've got patch-package patch sets generating automatically off PRs now, please try integrating the patch-package set and we would love feedback https://github.com/invertase/react-native-google-ads/actions/runs/1565648878

Will probably release shortly

@mikehardy mikehardy removed the help wanted Extra attention is needed label Jun 24, 2022
@patchuko
Copy link

patchuko commented Sep 4, 2022

Hi,

I added:
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
at the beginning of my test.js and it worked.

So now my app.test.js is like this:

import React from 'react';
import renderer from 'react-test-renderer';
import App from './App';
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');

describe('<App />', () => {
it("works", () => {
expect(1).toBe(1);
});
});

@elifpw
Copy link

elifpw commented Jan 11, 2023

Hi,

I'm still having this error @mikehardy can you help me please?

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

Successfully merging a pull request may close this issue.

5 participants