Upgrade old admob to Google Play Service

Credit This is a tutorial from : http://tutorialrich.com/extra-upgrade-old-admob-to-google-play-service/


I always follow this step to upgrade legacy android apps.


You should update to the latest Google Play service and it is better choice compare to standalone admob SDK. We are going to teach you how to update your old android code to the latest Google Play services.


Step 1:

Open your old Admob Project. Delete the GoogleAdMobAdsSDK.jar inside the libs folder. (Next : Just ignore the reference warning.)




Step 2:

Setup Google Play service.



Android SDK

1. Launch the SDK Manager in one of the following ways:

  • In Android Studio, click SDK Manager in the toolbar.

  • In Eclipse (with ADT), select Window > Android SDK Manager

2. Install the Google Play services SDK. Google Play Services

Scroll to the bottom of the package list, expand Extras, select Google Play services, and install it. The Google Play services SDK is saved in your Android SDK environment at /extras/google/google_play_services/. Note: Google Play services 4.0.30 (released November 2013) and newer versions require Android 2.3 or higher. If your app supports Android 2.2, you can continue development with the Google Play services SDK, but must instead install Google Play services for Froyo from the SDK Manager. 4. Make a copy of the Google Play services library project. If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it.
Screen Shot 2014-06-24 at 12.01.11 AMNote if you testing Google Play Services SDK.Google Mobile Ads SDK FAQ states that: If you keep getting the error ‘The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. the google play services resources were not foundYou can safely ignore this message. Your app will still fetch and serve banner ads.


After setup the Google Play Service.Right click on project properties and add the google-play-service in the Library section.

android play library


Step 3:

Remove the import import com.google.ads.* code .


and add the following code import com.google.android.gms.ads.*;



Step 4:

Open the AndroidManifest.xml and remove the <activity android:name=”com.google.ads.AdActivity”



add the following code :
<activity android:name="com.google.android.gms.ads.AdActivity"…/> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>


Step 5:

Remove the following code

AdView adView =newAdView(activity,AdSize.BANNER,


and add the following code.


AdView adView = (AdView)this.findViewById(R.id.adView);

    AdRequest adRequest = new AdRequest.Builder()




Step 6:

Remove the following code
AdRequest request =newAdRequest()



and add the following code
AdRequest request =newAdRequest.Builder()



Step 7:

If the you use the ads view inside the XML files instead of java code. Remove the following code.


















and add to the following code in xml layout and src code.


// Java code required.
// testDevices and loadAdOnCreate attributes are
// no longer available.

AdView adView = (AdView)this.findViewById(R.id.adView);


AdRequest adRequest = new AdRequest.Builder()






and modify the code in the xml.

Step 8:

Since you remove the GoogleAdmobJar, you must also remove the setting in order to compile the code.



On the project properties, go to Java Builder Path and remove the missing jar.


Next, clean the project and run the NewImage program.

Upgrade old admob to Google Play Service Upgrade old admob to Google Play Service Reviewed by Admin on 4:12 PM Rating: 5

No comments:

Powered by Blogger.