簡體   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