如何在React Native中解决“UIManager中未找到AIRMap”错误?

9
未处理的JS异常:不变式违规:在UIManager中找不到“AIRMap” requireNativeComponent。

此错误位于: 在AIRMap中(位于MapView.js:760) 在MapView中(位于App.js:25) 在RCTView中(位于View.js:43) 在应用程序中(位于renderApplication.js:32) 在RCTView中(位于View.js:43) 在RCTView中(位于View.js:43) 在AppContainer中(位于renderApplication.js:31)

如何在React Native iOS中修复此错误?


1
你修好了吗?:( 我没能让它工作。你能分享一下你是如何修复它的吗? - doobean
目前为止,相同的错误没有修复。 - Siraj Alam
你后来找到解决方案了吗?@ajnasaskar? - Stéphane de Luca
4个回答

1

添加至ios/YOUR_PROJECT_NAME/AppDelegate.m

@import GoogleMaps; // 如果要使用Google Maps,请添加这一行

以及

[GMSServices provideAPIKey:@"_YOUR_API_KEY_"]; // 使用从Google Console获得的api密钥添加这一行


我已经尝试过了,但仍然出现相同的错误。@KateYeEum 你找到解决方案了吗? - vemund

0

我也遇到了这个错误,我是这样解决的:

  1. 在你的项目中,打开 package.json 文件
  2. 在依赖项 react native maps 中应该像这样写:"react-native-maps": "https://github.com/react-community/react-native-maps.git"
  3. 在终端/cmd 中运行 npm-install 命令
  4. 别忘了链接:"react-native link react-native-maps"

  5. 最后运行:react-native run-ios/android

因为只有一个人被允许在 npm 上发布,所以我们应该使用 Git 来获取最新的更新等。


0
我已经将以下脚本添加到package.json中。它对我有用。
{
  "name": "your-app",
  "scripts": {
    "postinstall": "./node_modules/react-native-maps/enable-google-maps REPLACE_ME_RELATIVE_PATH_TO_GOOGLE_MAPS_INSTALL"
  }
}

-7
/*----------------Install----------------*/

npm install react-native-maps --save

/*----------------Get a Google Maps API key----------------*/

/*----------------Write this in Pod file----------------*/

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target '_YOUR_PROJECT_TARGET_' do
    rn_path = '../node_modules/react-native'
    rn_maps_path = '../node_modules/react-native-maps'

# See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
    pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
pod 'React', path: rn_path, subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
]

# React Native third party dependencies podspecs
pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
# If you are using React Native <0.54, you will get the following error:
    # "The name of the given podspec `GLog` doesn't match the expected one `glog`"
# Use the following line instead:
    #pod 'GLog', :podspec => "#{rn_path}/third-party-podspecs/GLog.podspec"
pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

# react-native-maps dependencies
pod 'react-native-maps', path: rn_maps_path
pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS
end

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
    target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
if target.name == "React"
    target.remove_from_project
end
end
end



/*----------------Write this in AppDelegate .m----------------*/

@import GoogleMaps

In didFinishLaunchingWithOptions method
    [GMSServices provideAPIKey:@"_YOUR_API_KEY_"];

/*----------------Now rut it with simulator or iOS device----------------*/

/*----------------

for more you can take reference of this :
https://github.com/react-community/react-native-maps

----------------*/

3
很好的复制粘贴。没有任何有用的信息,同样的文档已经被粘贴在这里了。 - Siraj Alam
我正在进行点踩操作,因为你粘贴了没有解释的代码。 - Daggie Blanqx - Douglas Mwangi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接