New Admob for Android: Switching from Admob SDK to Google Play Services API

Google announced on the 11th of February 2014 that they were deprecating the standalone Admob Android SDK. They will stop accepting apps using the old SDK on the 1st of August 2014. Ads will keep serving, but eventually you will have to switch over.

Also, legacy AdMob will be shutting down on 31st of August 2014, you have to upgrade to new AdMob following this guide.

I updated and found out that there are some points that you should notice.

Know your new AdMob Ad Unit ID

Apps you previously monetized in legacy AdMob used legacy Publisher IDs (which represented a string of 15 hexadecimal characters starting with the letter “a”, such as a143534390190de) to identify the ad units and legacy Mediation IDs (which represented a string of 16 character hexadecimal characters such as e124250129089251) for mediation.

New AdMob uses ad unit IDs to identify unique ad units in your apps, serve ads to those ad units, and manage AdMob Mediation if it's enabled. Ad unit ID has a format of ca-app-<publisherId>/<slotname>

The term publisherId now represents a unique account identifier with the format pub-xxxxxxxxxxxxxxxx (16 digits) and slotname identifies a unique ad space and has the format nnnnnnnnnn (10 digits).

Make sure your ad unit has the format ca-app-pub-xxxxxxxxxxxxxxxx/nnnnnnnnnn without any whitespace.

Change Admob SDK library

First of all, remove "libs/GoogleAdMobAdsSdk-6.4.1.jar". You won't be needing that anymore.

Secondly, import the Google Play Services library project into Eclipse. You can find it at "Android-SDK/extras/google/google_play_services/libproject/google-play-services_lib".

Add it to your project as a library via right click (on project) > Properties > Android > Library > Add > google-play-services_lib.

Change in your AndroidManifest.xml

In your AndroidManifest.xml file, add in this meta-data tag.

Then, replace ad activity declaration with the new one

Generate AdView

Without XML

If you're creating AdViews from code then you'll have to tweak it a little.

With XML

In your layout file, do some replacements.

and

Look up and Load

Using Google Play Services API, all AdViews must be fetched in code.

Done!

Check out the Google migration guide if you're also using AdListener interfaces or if anything in this post was confusing.

Other than that, your project should be good to go!


You may want to read:


Comments

  1. Google migration is one of the most important things for a business in our days. In case of a downtime, everything keeps working as usual!

    ReplyDelete

Post a Comment

Popular posts from this blog

How to wrap a C# library for using in Java, a folk tale about an idiot coding at midnight.