繁体   English   中英

Expo 应用程序因 react-native-google-mobile-ads 崩溃 [在 app.json 中的 react-native-google-mobile-ads 键中找不到 ios_appd_id 键]

[英]Expo app crashes with react-native-google-mobile-ads [ios_appd_id key not found in react-native-google-mobile-ads key in app.json]

我在使用 react-native-google-mobile-ads 时遇到此错误: https://github.com/invertase/react-native-google-mobile-ads/issues/194

我的应用程序正在使用带有 EAS 构建系统的 expo 托管工作流。

我的应用程序为 android 构建,但在 iOS 上失败,出现以下错误:在ios_appd_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it. ios_appd_id key not found in react-native-google-mobile-ads key in app.json. App will crash without it. 这很奇怪,因为 app.json 有正确的定义:

"react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-xxx",
    "ios_app_id": "ca-app-pub-xxx",
    "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
  }

无论我如何更改我的代码或依赖项,这都会不断出现。 为了调试并找到可重现的示例,我慢慢构建了一个新项目,该项目是通过 expo init 创建的(就像我的初始项目一样)。 但是,我现在已经将每个文件完全复制到新的、新鲜的应用程序中,包括所有资产(图标、飞溅),我根本无法重现该错误。 这两个应用程序是彼此的精确副本(代码,app.json,eas.json,package.json)事实上,新的新应用程序模式在开发和生产模式下都可以正常运行。 我很困惑。 上述错误发生在构建过程的“运行快车道”阶段。

带有错误的 fastlane 日志在这里: https://pastebin.com/4cD8T3Sn来自新应用程序的日志完全相同,只是日志的最后几行是成功消息:

› Copying   ios/googleadmobtest/Supporting/Expo.plist ➜ ./Expo.plist
› Compiling googleadmobtest » SplashScreen.storyboard
› Preparing googleadmobtest » Info.plist
› Executing googleadmobtest » Bundle React Native code and images
› Generating debug googleadmobtest » googleadmobtest.app.dSYM
› Executing googleadmobtest » [CP] Copy Pods Resources
› Executing googleadmobtest » [CP-User] [RNGoogleMobileAds] Configuration
› Signing   googleadmobtest » googleadmobtest.app
› Creating  googleadmobtest » googleadmobtest.app
› Archive Succeeded
Generated plist file with the following values:
▸ -----------------------------------------
▸ {
▸   "method": "ad-hoc",
▸   "provisioningProfiles": {
▸     "com.arham23.googleadmobtest": "c88fe3cb-0ed2-427d-ae68-ec6a484dccca"
▸   },
▸   "signingStyle": "manual"
▸ }
▸ -----------------------------------------
$ /usr/bin/xcrun /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.205.2/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh -exportArchive -exportOptionsPlist '/var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/gym_config20220815-4163-q9vcsf.plist' -archivePath /Users/expo/Library/Developer/Xcode/Archives/2022-08-15/googleadmobtest\ 2022-08-15\ 23.44.51.xcarchive -exportPath '/var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/gym_output20220815-4163-1ishkbk' OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/turtle-v2-9ac5a45d-33ef-4193-bf51-33b05b2e1e98.keychain"
Compressing 1 dSYM(s)
$ cd '/Users/expo/Library/Developer/Xcode/Archives/2022-08-15/googleadmobtest 2022-08-15 23.44.51.xcarchive/dSYMs' && zip -r '/Users/expo/workingdir/build/ios/build/googleadmobtest.app.dSYM.zip' *.dSYM
▸   adding: googleadmobtest.app.dSYM/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/DWARF/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/DWARF/googleadmobtest (deflated 75%)
▸   adding: googleadmobtest.app.dSYM/Contents/Info.plist (deflated 44%)
Successfully exported and compressed dSYM file
Successfully exported and signed the ipa file:
/Users/expo/workingdir/build/ios/build/googleadmobtest.ipa

我可以提供任何其他必要的信息,我对 expo 有点陌生并且反应原生,所以我不确定什么是相关的。 我的原始应用程序的配置似乎有问题,但我不知道问题可能是什么。 我想尝试删除所有 ios pod 并重新安装,但该应用程序由 expo 管理,我不确定如何在 expo CLI 中完成此操作。 任何帮助将不胜感激。

为了解决这个错误,我将配置分成两个文件。 Expo 默认加载app.config.jsonapp.jsonreact-native-google-mobile-ads读取app.json

app.json

{ 
    "react-native-google-mobile-ads": {
        ...app ids
    }
}

app.config.json

{
    "expo": {
        "name": ...
        ...
    }
}

我遇到了同样的问题,然后我尝试将 app.json 拆分为 2 个部分,如下所示:在 app.json 中,在复制和粘贴以下代码之前

{
 "react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
    "ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
 }
}

从 https://docs.page/invertase/react-native-google-mobile-ads#configure-outbound-requests 我将"name": "...", "displayName": "...",移至一个名为app.config.json的新文件与 app.json 位于同一目录。 结论: app.json

{
"react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
    "ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
  }
}

app.config.json

{
 "name": "...",
  "displayName": "...",
}

Note that: because you changed the app.json -> app.config.json so wherever you implement data from app.json you need to change to app.config,json For example in my index.js has a line import {name as appName} from './app.json'改成import {name as appName} from './app.config.json'希望大家能解决这个问题,谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM