react-native-keep-awake icon indicating copy to clipboard operation
react-native-keep-awake copied to clipboard

'ReactNativeKCKeepAwake' could not be found. Verify that a module by this name is registered in the native binary.

Open raduvarga opened this issue 1 year ago • 5 comments

I am getting the above error after installing the library. On iOS, I figured I have to install the pods and then the error went away. Are there further Android installation instructions?

raduvarga avatar Jan 23 '24 13:01 raduvarga

Same here. Cant run on android.

aybarska avatar Feb 05 '24 11:02 aybarska

We have a app running with older builds, I haven't touched react-native in a while so I cannot debug this atm.

sayem314 avatar Feb 15 '24 15:02 sayem314

Same on iOS latest RN

SpaceTimeEvent avatar Feb 22 '24 03:02 SpaceTimeEvent

I am getting a similar error, but only when running tests with jest:

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'ReactNativeKCKeepAwake' could not be found. Verify that a module by this name is registered in the native binary.

Version 1.2.3

Any ideas?

owlfrancesco avatar Mar 12 '24 20:03 owlfrancesco

Hey @owlfrancesco, I also encounter the same.

I solved it by adding a mock for TurboModuleRegistry.getEnforcing(...), as per this stackoverflow thread

jest.mock('react-native/Libraries/TurboModule/TurboModuleRegistry', () => {
  const turboModuleRegistry = jest.requireActual('react-native/Libraries/TurboModule/TurboModuleRegistry');
  return {
    ...turboModuleRegistry,
    getEnforcing: (name) => {
      // List of TurboModules libraries to mock.
      const modulesToMock = ['ReactNativeKCKeepAwake'];
      if (modulesToMock.includes(name)) {
        return null;
      }
      return turboModuleRegistry.getEnforcing(name);
    },
  };
});

rebeccachin avatar Mar 18 '24 18:03 rebeccachin