iOS Question I got error when using iAdMob to display Banner Ad

Modern_Digital

Member
Licensed User
Longtime User
Hi,

I got error when using iAdMob to display Banner Ad, This is the code what i use:

the code in Application_Start :

B4X:
       AdView1.Initialize("AdView1","ca-app-pub-**************~**********",FrmMain,AdView1.SIZE_BANNER)
       AdView1.SetTestDevices(Array("******************************"))
       AdView1.LoadAd
       AdView1.Alpha = 1
       AdView1.Visible = True
       AdView1.BringToFront
          
       FrmMain.RootPanel.AddView(AdView1, 0, 100%y - 50dip, 100%x, 50dip)

Note : I replaced the real numbers with stars.

This is the error message :

Application_Start
Error occurred on line: 111 (Main)
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
Stack Trace: (
CoreFoundation <redacted> + 252
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation <redacted> + 0
result GADVerifyApplicationID + 152
result GADVerifyApplicationID + 3172
result GADVerifyApplicationID + 4172
result GADDispatchAsyncSafeMainQueue + 56
result GADVerifyApplicationID + 4116
result GAD_GADAdSource_arm64_7_44_0 + 1832
result GAD_GADInternalBannerView_arm64_7_44_0 + 9156
result GAD_GADInternalBannerView_arm64_7_44_0 + 5728
result GADDispatchAsyncSafeMainQueue + 56
result GAD_GADInternalBannerView_arm64_7_44_0 + 4956
result GAD_GADInternalBannerView_arm64_7_44_0 + 6324
result GAD_GADBannerView_arm64_7_44_0 + 3984
result -[B4IAdView LoadAd] + 236
CoreFoundation <redacted> + 144
CoreFoundation <redacted> + 284
result +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
result -[B4IShell runVoidMethod] + 232
result -[B4IShell raiseEventImpl:method:args::] + 1792
result -[B4IShellBI raiseEvent:event:params:] + 1372
result __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
libdispatch.dylib <redacted> + 24
libdispatch.dylib <redacted> + 16
libdispatch.dylib <redacted> + 1012
CoreFoundation <redacted> + 12
CoreFoundation <redacted> + 2272
CoreFoundation CFRunLoopRunSpecific + 552
GraphicsServices GSEventRunModal + 100
UIKit UIApplicationMain + 236
result main + 124
libdyld.dylib <redacted> + 4
)
Application_Active

And i want to mention that i copied the GoogleMobileAdsSdkiOS-7.44.0 to the builder lib folder.

What should I do to make it work correctly?

Thank you.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hi,

I got error when using iAdMob to display Banner Ad, This is the code what i use:

the code in Application_Start :

B4X:
       AdView1.Initialize("AdView1","ca-app-pub-**************~**********",FrmMain,AdView1.SIZE_BANNER)
       AdView1.SetTestDevices(Array("******************************"))
       AdView1.LoadAd
       AdView1.Alpha = 1
       AdView1.Visible = True
       AdView1.BringToFront
        
       FrmMain.RootPanel.AddView(AdView1, 0, 100%y - 50dip, 100%x, 50dip)

Note : I replaced the real numbers with stars.

This is the error message :



And i want to mention that i copied the GoogleMobileAdsSdkiOS-7.44.0 to the builder lib folder.

What should I do to make it work correctly?

Thank you.

Firstly, it looks like you are using your application ID & not the ad unit ID in your Initialize call. The ad unit ID doesn't have the "~" - it has the "/".

Secondly, per the AdMob documentation (https://developers.google.com/admob/ios/quick-start), you need to add the GADApplicationIdentifier to your plist file & include your AdMob Application ID, otherwise you will get an intialization error (exactly what it says in the error you got).

Update your Info.plist
In your app's Info.plist file, add a GADApplicationIdentifier key with a string value of your AdMob app ID. You can find your App ID in the AdMob UI.

You can make this change programmatically:



<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
Or, edit it in the property list editor:

admob_app_id_plist.png


Note: If you haven't created an AdMob account and registered an app yet, now's a great time to do so. In a real app, it is important that you use your actual AdMob app ID, not the one listed above. If you're just looking to experiment with the SDK in a Hello World app, though, you can use the sample App ID shown above.

Warning:
This step is required as of Google Mobile Ads SDK version 7.42.0. Failure to add add this Info.plist entry results in a crash with the message: "The Google Mobile Ads SDK was initialized incorrectly."

As well as reading tutorials, etc... in the B4X forums, it helps a lot if you take the time to read the documentation related to whatever you're trying to implement - in this case the Getting Started guide for setting up AdMob in an iOS app. There are often changes implemented in new versions of the AdMob SDK & those changes won't always be reflected in the info you find on the B4X forums.

- Colin.
 
Upvote 0

Modern_Digital

Member
Licensed User
Longtime User
Thank you very much guys,

I Added this line:

B4X:
#PlistExtra: <key>GADIsAdManagerApp</key><true/>

and its works now correctly, I appreciate your help.
 
Upvote 0

Similar Threads

Replies
6
Views
1K
D
  • Question
Replies
1
Views
1K
  • Locked
  • Article
B4i Library iAdMob
Replies
108
Views
29K
Top