代码之家  ›  专栏  ›  技术社区  ›  kalememre

向Ionic项目添加AdMob插件时发生Xcode错误

  •  0
  • kalememre  · 技术社区  · 7 年前

    Terminating app due to uncaught exception
    'GADInvalidInitializationException', reason: 
    'The Google Mobile Ads SDK was initialized incorrectly. 
    Google AdMob publishers should follow instructions here: 
    
    https://googlemobileadssdk.page.link/admob-ios-update-plist 
    to include the AppMeasurement framework, 
    set the -ObjC linker flag, and set 
    GADApplicationIdentifier with a valid App ID. 
    
    Google Ad Manager publishers should follow 
    instructions here: 
    https://googlemobileadssdk.page.link/ad-manager-ios-update-plist
    
    0 回复  |  直到 7 年前
        1
  •  31
  •   Kilian Perdomo Curbelo    7 年前

    这个问题已经有两天了。问题似乎是xcode项目的plist文件没有正确获取admob设置。所以不得不像这样手动添加它们:

    打开你的应用程序名称-信息列表在“ionic project root/platforms/ios/your app name/”下添加以下行:

    <key>GADIsAdManagerApp</key>
    <true/>
    <key>GADApplicationIdentifier</key>
    <string>ca-app-pub-XXXXXXX~YYYYYYY</string>
    

        2
  •  10
  •   bpolat    7 年前

    enter image description here

    有一个新的过程,您需要为添加GADIsAdManagerApp密钥信息列表布尔值为YES的文件

        3
  •  7
  •   TheBosti    6 年前

    有了Admob插件(我刚刚在ioiv V3中尝试过),您可以将其添加到 ./配置.xml 在平台ios下自动填充app name-信息列表在每次生成时进行文件。

    <platform name="ios">
       <config-file parent="GADApplicationIdentifier" target="*-Info.plist">
          <string>ca-app-pub-12345/12345</string>
       </config-file>
    
       <config-file parent="GADIsAdManagerApp" target="*-Info.plist">
          <true />
       </config-file>
    
       ... (other lines) ...
    
    </platform>
    

    cordova prepare 重新生成文件(另外删除ios平台并使用以下命令重新安装: ionic cordova platform rm ios , ionic cordova platform add ios