zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.04k stars 828 forks source link

Fatal Exception: com.facebook.react.common.JavascriptException Error: react-native-permissions: NativeModule.RNPermissions is null #809

Closed harshil-gosquire closed 1 year ago

harshil-gosquire commented 1 year ago

Bug summary

We are facing strange crash which is happening to some devices with live playstore version of the app, we have error logging setup with firebase crashlytics, smartlook and testfairy - at all 3 places we are getting same error log, suddenly our users started facing this in a stable app.

Here is the full bug report

Fatal Exception: com.facebook.react.common.JavascriptException: Error: react-native-permissions: NativeModule.RNPermissions is null. To fix this issue try these steps:
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then clean, rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
• If you are getting this error while unit testing you need to mock the native module. You can use this to get started: https://github.com/zoontek/react-native-permissions/blob/master/mock.js
If none of these fix the issue, please open an issue on the Github repository: https://github.com/zoontek/react-native-permissions, js engine: hermes, stack:
anonymous@1943:1018
h@2:1585
d@2:958
o@2:496
Pe@2161:18604
anonymous@2161:18014
Ul@55:66831
ja@55:84504
anonymous@55:82832
Y@177:2883
e@177:400
anonymous@84:1256
k@84:499
callTimers@84:2652
value@36:3556
anonymous@36:673
value@36:2503
value@36:645

       at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:72)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
       at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
       at android.os.Handler.handleCallback(Handler.java:942)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
       at android.os.Looper.loopOnce(Looper.java:226)
       at android.os.Looper.loop(Looper.java:313)
       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
       at java.lang.Thread.run(Thread.java:1012)

Library version

3.6.1

Environment info

System:
    OS: macOS 13.5.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 110.30 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.12.0 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9477386
    Xcode: 14.3/14E222b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.4 => 0.67.4 
    react-native-macos: Not Found

Steps to reproduce

Since it is only happening with live version of the app we do not have solid reproduction steps. we are using checkNotifications() function on the screen where the app is crashing

Reproducible sample code

checkNotifications()
      .then(({status}) => {

        check(
          Platform.OS === 'ios'
            ? PERMISSIONS.IOS.CAMERA
            : PERMISSIONS.ANDROID.CAMERA,
        )
          .then(result => {

          })
          .catch(() => {

          });
      })
      .catch(() => {

      });
  };
jaydeep911 commented 1 year ago

@zoontek Can you please suggest a solution?

jaydeep911 commented 1 year ago

https://github.com/zoontek/react-native-permissions/issues/757#issuecomment-1471431059

Is this a valid solution @zoontek ?

harshil-gosquire commented 1 year ago

@zoontek please reopen the issue as none of the existing issues here does not have scenario which we are facing with few devices only and on live version of the app on the playstore - if you can provide us more inputs on this it will be helpful

zoontek commented 1 year ago

Update to latest react-native and to latest react-native-permissions versions first.

I don't offer free support for deprecated versions, it's in the README.

Open another issue when you have confirmation that this one has not been solved after that.