Problem when trying to install AdMob SDK

When I run my app I get this error:“The Google Mobile Ads SDK was initialized incorrectly. Google AdMob publishers, 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, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist”.I did all of googles steps.

Have you followed those instructions? At what point do you see this error?

Does it show a specific line of code?

The build succeeds for 2 secs and after that it closes and says the upper message along with :

0x1b17e3fa8 <+8>: b.lo 0x1b17e3fc4 <+36>. Thread 3: “The Google Mobile Ads SDK was initialized incorrectly. Google AdMob publishers, 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, follow instructions here: https://googlemobileadssdk.page.link/ad-manager-ios-update-plist

What have you done so far? Only added the SPM package?

I added the SPM package and wrote the code in view controller and on app delegate

You have this in your AppDelegate, and you added the right info to the Info.plist

GADMobileAds.sharedInstance().start(completionHandler: nil)

yes I copied the google info open the source code and changed only the app key

So you’re using UIKit, and you’re adding the code to the right function in the AppDelegate?

Also what have you written in the ViewController?

this is what I wrote in the view controller

import UIKit
import GoogleMobileAds

class ViewController: UIViewController, GADBannerViewDelegate {

var bannerView: GADBannerView!
@IBOutlet weak var buttontap: UIButton!

override func viewDidLoad() {
super.viewDidLoad()

  bannerView.adUnitID = "ca-app-pub-“
    bannerView.rootViewController = self
  bannerView.load(GADRequest())
// In this case, we instantiate the banner with desired ad size.
bannerView = GADBannerView(adSize: GADAdSizeBanner)
  bannerView.delegate = self
addBannerViewToView(bannerView)

}

func addBannerViewToView(_ bannerView: GADBannerView) {
bannerView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(bannerView)
view.addConstraints(
[NSLayoutConstraint(item: bannerView,
attribute: .bottom,
relatedBy: .equal,
toItem: view.safeAreaLayoutGuide,
attribute: .bottom,
multiplier: 1,
constant: 0),
NSLayoutConstraint(item: bannerView,
attribute: .centerX,
relatedBy: .equal,
toItem: view,
attribute: .centerX,
multiplier: 1,
constant: 0)
])
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
print(“bannerViewDidReceiveAd”)
}
}

}

1 Like

Has AdMob indicated whether or not your app has successfully connected to it? Also side note you can definitely make these constraints way easier

I deleted the ad unit ID, because you shouldn’t share that publicly

Do you also have Firebase in the project? Or only AdMob?

only admob

plz help

I retried with a different app and it say the google Mobile Ads Sdk was initialised without app measurement

@efthimis You are needing step by step instructions on how to install ads. Have you tried checking out resources online? https://www.youtube.com/results?search_query=instal+AdMob+SDK+ios

I know Mikaela Caron is more than happy to help, but there’s a difference between helping, and walking you through an entire process.

1 Like

I would try to uninstall the package and then reinstall it (because if you’ve followed all the steps, it should work)

I recently installed AdMob with SPM and didn’t have issues after following the instructions you linked, but I did also have Firebase Analytics installed too

But also I would HIGHLY recommend adding at least Firebase analytics (cause AdMob and analytics work well together, and you can do more with them together)

I made it work just by adjusting the package from 10.0.0 ti 9.0.0

Oh geez haha!
You should actually set it to “up to next major version” more so than a specific version number

Ok I also wrote -ObjC on linking tab and that’s it

1 Like

and yes I set it to 9.0.0 up to next major version thank you a lot you are the BEST!

1 Like