moaazsidat / react-native-qrcode-scanner

A QR code scanner component for React Native.
MIT License
2.04k stars 516 forks source link

react-native-permissions: NativeModule.RNPermissions is null #411

Open BajajSaajan opened 1 year ago

BajajSaajan commented 1 year ago

I want to integrate this package only in android. While integration i am getting this error as below, kindly assist.

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/react-native-community/react-native-permissions/blob/master/mock.js

webmonch commented 1 year ago

Also getting this error.

react-native-permissions is set up correctly. I use them in the same project and everything is ok.

BajajSaajan commented 1 year ago

@mmvlad I tried. as per the documentation npm install react-native-permissions --save react-native link react-native-permissions

Is there anything i am missing?

zakharov-dy commented 1 year ago

One of the typical solutions for such a case is to override dependencies. Override the react-native-permissions dependency for react-native-qrcode-scanner. For npm we need to use overrides, and for resolutions for yarn.

So for this code works just delete node_modules folder, yarn.lock file, and add this code to package.json

  "resolutions": {
    "react-native-permissions": "^3.8.0"
  },
  "overrides": {
    "react-native-qrcode-scanner": {
      "react-native-permissions": "^3.8.0"
    }
  },

https://stackoverflow.com/questions/75772965/error-react-native-permissions-nativemodule-rnpermissions-is-null

ReddSpark1 commented 1 year ago

I'm still having this issue. I tried deleting the react-native-qrcode-scanner\node_modules folder,. Then added the code above to the package.json file of my app. This however then gives me RNPermissionsModule' could not be found. And I have also been getting Invariant Violation: "main" has not been registered.

Pankaj-R commented 1 year ago

Just upgrade your "react-native-permissions" library to "3.6.0", and the issue will removed. I was facing this with my Camera and "react-native-qrcode-scanner" lib.Thanks

cokron commented 1 year ago

The solution provided by @zakharov-dy worked for me. I love react-native-qrcode-scanner. This issue is annoying, it took me an hour to find this solution, so dear @moaazsidat if you could fix this, it would be great and probably help many people! Thank you!