Debugging "Native module cannot be null"

I’m trying to update an inherited project from SDK 28 to SDK 37, and am running into an error on the iOS simulator which I can’t quite figure out.

Invariant Violation: Native module cannot be null.

There isn’t much in the way of logs, either in the terminal running expo start -c or in the browser tab that command opens up. On the simulator, there’s something of a stack but I’m not really able to understand it.

constructor (NativeEventEmitter.js:36:16)
<global> (index.js:5)
loadModuleImplementation (require.js:322:6)
<unknown> (AppEntry.bundle?platform=...=false&hot=false:128811:65)
loadModuleImplementation (require.js:322:6)
<global> (AppEntry.js:3)
loadModuleImplementation (require.js:322:6)
guardedLoadModule (require.js:201:45)
global code (AppEntry.bundle?platform=...y=false&hot=false:261916:4)

Double-clicking that <global> (index.js:5) entry in the simulator brings up node_modules/react-native-appsflyer/index.js, the first few lines of which are:

1: import {NativeEventEmitter, NativeModules} from "react-native";
3: const { RNAppsFlyer }        = NativeModules;
4: const appsFlyer              = {};
5: const eventsMap              = {};
6: const appsFlyerEventEmitter  = new NativeEventEmitter(RNAppsFlyer);

The output of expo diagnostics:

      OS: macOS 10.15.6
      Shell: 5.0.18 - /usr/local/bin/bash
      Node: 12.18.4 - /usr/local/bin/node
      Yarn: 1.22.5 - /usr/local/bin/yarn
      npm: 6.14.6 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
      iOS SDK:
        Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
      Android SDK:
        API Levels: 30
        Build Tools: 30.0.2
        System Images: android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
      Android Studio: 4.0 AI-193.6911.18.40.6626763
      Xcode: 12.0/12A7209 - /usr/bin/xcodebuild
      expo: ^37.0.0 => 37.0.12 
      react: 16.9.0 => 16.9.0 
      react-dom: 16.9.0 => 16.9.0 
      react-native: => 0.61.4 
      react-navigation: ^4.2.0 => 4.4.1 
      expo-cli: 3.27.7
    Expo Workflow: managed

Any tips on where to go from here? Thanks!

Hm looks like expo managed projects don’t support native modules, so I guess I need to eject? Not sure how this ever worked (this project was last updated 2 years ago). I’ll try ejecting and see where that gets me.

right, expo managed projects don’t support custom native modules at the moment. so you would need to eject. we definitely never included AppsFlyer (although you can use Branch in the managed workflow) so i imagine if this app ever worked it probably was ejected or this particular feature was silently failing.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.