You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用Android正常运行,iOS启动崩溃问题求助

问题定位

崩溃的核心原因是Google Mobile Ads SDK初始化时未读取到有效的应用ID,查看你提供的info.plist可以发现,GADApplicationIdentifier配置被错误嵌套在UISupportedInterfaceOrientations~ipad的数组内部,导致iOS系统无法识别这个配置项。

修复方案
  1. 打开iOS项目的info.plist文件(可通过Xcode编辑Runner目录下的文件,或直接修改源码)
  2. 将GADApplicationIdentifier及其对应值从UISupportedInterfaceOrientations~ipad数组中移出,放到<dict>的根层级下
  3. 清理UISupportedInterfaceOrientations~ipad数组中多余的<true/>节点(数组仅允许存放方向字符串)

修正后的关键代码片段:

<!-- 修正后的iPad屏幕方向配置 -->
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

<!-- 移至根层级的AdMob应用ID配置 -->
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
额外验证点
  • 你使用的ca-app-pub-3940256099942544~1458002511是Google官方测试ID,用于开发阶段测试是合法有效的
  • 确保Flutter代码中正确初始化广告SDK,比如在main函数中调用MobileAds.instance.initialize()

内容的提问来源于stack exchange,提问作者Pramod Yadav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 12:05:03