Google Mobile Ads (via Google Play Services) migration + Android 2.1-2.2 legacy support

283 views
Skip to first unread message

Chris

unread,
Mar 27, 2014, 4:55:51 PM3/27/14
to google-adm...@googlegroups.com
Hi all,

I saw the info that Google Mobile Ads is now offered through Google Play services, when I checked for an updated version of the AdMob SDK.

I read the setup guide (https://developer.android.com/google/play-services/setup.html), the migration guide (https://developers.google.com/mobile-ads-sdk/docs/admob/play-migration) and the step by step guide (https://developers.google.com/mobile-ads-sdk/docs/#play).

At the moment I’m using GoogleAdMobAdsSdk-6.4.1.jar and my apps support devices running Android 2.1 – 4.4. As Play Services are available for devices running 2.3 and higher only, the following questions arose, before I start to do the migration:

1. How do deliver ads to 2.1 & 2.2 devices, when I start using the Google Play Service to handle ads?

2. Is it possible to keep the GoogleAdMobAdsSdk-6.4.1.jar in the project to support 2.1 & 2.2 devices, while using the Play Services for everything >= 2.3?
Will something like this work:

    private AdView adViewLegacy;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // setup the app
        .
        // init ads
        setUpAd();
    }
   
    public void setUpAd() {
        // ad setup using 'Google Play Services'
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            // new code using Play Services
            .
        }
        // legacy ad code for Android 2.1 & 2.2
        else {
            adViewLegacy = new AdView(this, AdSize.SMART_BANNER, ADMOB_PUBLISHER_ID);  // create the adView
            ((LinearLayout)findViewById(R.id.chartStatisticPeriods_adLayout)).addView(adViewLegacy);  // add adView to Layout
            AdRequest adRequest = new AdRequest(); // create ad request
            adViewLegacy.loadAd(adRequest); // start loading the ad in the background.
        }
    }
   
3. On a 2.2 device, using the GoogleAdMobAdsSdk-6.4.1.jar and the legacy part of the code from above, I see the following log output: "03-27 21:12:38.108: E/ActivityThread(1202): Failed to find provider info for com.google.plus.platform"

Ads are displayed properly on the 2.2 device, but I don't see this log output on a 4.4 device, though.
Is this output related to the Google Play services not being supported on 2.2 (and 2.1) devices? Or does anyone know where this is coming from?


Thanks for your time,

Chris

Amy Quispe (AdMob SDK Team)

unread,
Apr 1, 2014, 7:05:35 PM4/1/14
to google-adm...@googlegroups.com
Hi Chris,

1.) Google Play Services requires a min SDK of 9 (i.e. Gingerbread) so you won't be able to use it to supply ads for 2.1 and 2.2. if you really want to do this, you could supply ads using the old SDK for 2.1 and 2.2.

2) Yes, you'd have to check the version in order to decide what to do wrt code. You'll also have to specify that you're calling the com.google.android.gms.ads.AdView class in the Google Play Services code, whereas when you're using the legacy version you'd have to specify that you're calling the com.google.ads.AdView class (and do this for other name collisions). But you should be able to do it. You'll also need to remove the com.google.ads classes from Google Play Services so that they don't conflict with the old SDK.

3) This is because the 2.2 device is still using GPS (for a plus button or something?). You'll need to make sure when running on 2.1 or 2.2 that nothing in GPS is being used.

If you really want to continue supporting 2.1 and 2.2 and don't need anything else in Google Play Services, I'd recommend just using the old SDK for now. However, starting August 1st, we won't be accepting updates that use the old SDK since it doesn't use Ad ID, so you'd have to drop 2.1 and 2.2 after that point anyway, so you have a choice between doing that now or in August. It's your decision, of course, how you want to proceed.

How this helps.

Amy Quispe

barışcan kayaoğlu

unread,
Aug 7, 2014, 7:36:29 AM8/7/14
to google-adm...@googlegroups.com
Hello Amy,

About the using the old SDK for 2.1 and 2.2 versions, how can I create a request object from the old SDK? I created two separate methods for requesting like this

private void loadAd(com.google.ads.AdView adView) {

...

}
private void loadAd(com.google.android.gms.ads.AdView adView) {

...

}
 
What I can't achieve is to create a request object for the AdView in standalone admob jar because the constructor is private and there is no creator class that using the private constructor. I'm not 100% sure that com.google.ads.AdView is from "GoogleAdMobAdsSdk-6.4.1.jar", there might be another class with same package name in play service as well. You also mentioned something about removing the AdMob classes from play service library. How can we achieve this?

Thank you.

barışcan kayaoğlu

unread,
Aug 7, 2014, 7:44:49 AM8/7/14
to google-adm...@googlegroups.com
Hi Amy,

After I remove the play service from the project, I can see that AdRequest constructor becomes public, so it is as i suspected, there is a deprecated class "com.google.ads.AdView adView" in play service. Is there a way to remove it?

Thank you

Kunal Verma

unread,
Aug 7, 2014, 7:56:44 AM8/7/14
to Google AdMob Ads Developers
Hi 

As Amy said above, if you want to continue supporting Android 2.1 and Android 2.2, keep using the old SDK. Keep the current version published in the google play store. IMO Also, add another version of your app with minimum API requirement 9. What Google play may do is give priority to the new update for all the 2.3 and above devices and leave the previous version for 2.1 and 2.2.

I did 2 apk's when I needed one for small screen and the second one for the rest of devices. Give it a try, it may work.

Best,
Kunal




--

---
You received this message because you are subscribed to the Google Groups "Google AdMob Ads Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

barışcan kayaoğlu

unread,
Aug 7, 2014, 8:26:24 AM8/7/14
to google-adm...@googlegroups.com
Hello Kunal,

I was trying to achieve what you said by using Flavor support in Gradle. The problem was not with the min SDK requirement but it was the private constructor of AdRequest in play service. I wanted to use a single class using both libraries but with the same namespaces, I guess standalone AdMob and play service cannot co exist. I still don't get why there is a deprecated AdRequest class with private constructor without a builder or factory class in play service. If the idea was to prevent users to use it, then they could just remove the class from the library itself. Anyhow, I think i will use two separated classes to use AdMob and separate them in gradle and generate two apk as you said above. This way play service and the class that uses play service AdMob won't be compiled because of the flavor.

Thank you.

I.D.E.

unread,
Aug 7, 2014, 3:49:30 PM8/7/14
to google-adm...@googlegroups.com
I still have 9.9% of my active user base that uses Android 2.1 or 2.2 devices.

Now there is no way for these users to receive an app update.

So we are forced to abandon a large number of our users, due to Google Play Services.
Reply all
Reply to author
Forward
0 new messages