我面临这个错误,而启动React原生Android应用程序。Error: react-native-permissions: NativeModule.RNPermissions is null. To fix this issue try these steps: • If you are using CocoaPods on iOS, run
吊舱安装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 If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-permissions
我已经按照错误正文中提到的步骤没有运气。我遵循的步骤:
- pod安装
1.清理并重建应用程序 - npxReact-天然-清洁-项目
我的pod文件:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
# pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
platform :ios, '11.0'
target 'BayQi' do
pod 'react-native-contacts', :path => '../node_modules/react-native-contacts'
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'BayQiTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
end
target 'BayQi-tvOS' do
# Pods for BayQi-tvOS
target 'BayQi-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
1条答案
按热度按时间wfsdck301#
在花了两天时间调试
react-native-permissions
之后,我发现问题出在react-native-qrcode-scanner
上。它的依赖项中包含
"react-native-permissions": "^2.0.2"
,但当前版本为"react-native-permissions": "^3.8.0"
。此版本的
react-native-permissions (3.8.0)
具有重大更改。快速修复
1.安装
react-native-permissions
并按照安装说明进行操作。1.删除
node_modules/react-native-qrcode-scanner/node_modules/react-native-permissions
,因为它安装了弃用的2.0.2
。(每次清除node_modules时都需要执行此操作)在您的示例中,需要找到将
react-native-permissions
作为依赖项安装的库,然后删除node_modules/*specific-library*/node_modules/react-native-permissions
https://github.com/moaazsidat/react-native-qrcode-scanner/issues/403