Recently Google announced that their Ad program for Android device Admob leaves old Admob SDK and moving to new Admob with Google Play Services package. Obsolete Admob publishers will not get impressions if don’t move to the new Admob with Play service. In this tutorial I am going to unveil How to configure new Admob using Google Play services.
Problem: Configure New Admob services for Android
Difficulty: IntermediateAdditional Requirements: copy of Google Play Services package, Admob Account, Admob publisher ID.
Step : 1 Create New Site/AppNote : You can skip this method if have an existing app if so save your Publisher ID for future enhancement.
1. Go to Admob.com
2. Click on Sites & Apps tab and Click Add Site/App
3. Select Android from List
4. Enter you App Name (example Ad Revenue Calculator)
5. Enter the Android Package URL (example market://details?id=<com.bigknol.adrevenue.calculator>) make sure that the id points to correct package name of your project.
6. Select your Application category (Example Productivity)
7: Add your App description
8. Select Keyword Target Ads
9. Press continue button.
10. You can download the AdMob SDK after completing the above steps. Copy the App publisher ID from the final step.
Note : GoogleAdMobAdsSdk-6.4.1.jar is obsolete, you don’t want to use it on your app.
Step 2: Install Google Play Services to SDK1. Before you getting started with new Admob service you must install Google Play Services package in SDK, It will be stored in <android sdk>/extras/google/ directory. Open up your Android SDK Manager from Window menu of Eclipse IDE. Move down and go to Extras tick Google Play services (If you are targeting Android Froyo users you need to tick Google Play services for Froyo also) Install all required packages from Android SDK Manager.
2. Copy the Google Play services package.
Many developers forget to move a copy of extras package to workspace for making a reference to project. So you should take a copy of Google play services from <android sdk>/extras/google/ and paste it on your workspace.
3. Linking Google Play services package to project
If you want to use any class of AdMob package you must reference it properly. Otherwise you may get errors like “Admob Class Not found Exceptions”. How to link it? First you need to import the google-play-services_lib to current workspace.
File > Import > Android > Existing Android Code Into Workspace
Browse it from google_play_services/libproject/google-play-services_lib.
Warning: Don’t browse the original Google play services libproject from <android-sdk>/extras/google/google_play_services. Make sure that you have taken libproject from the copied version of Google play services in the workspace.
Step 3: Referencing to Current projectRight click on your project Select Properties
Click on Android, press Add button from Library then choose the google-play-services_lib as library. Click on Apply button then finally OK
Now you can use com.google.android.gms.ads methods and classes in your project.
Step 4: Setting up Android Manifest File for New Admob SDKYour android manifest file should have required permissions for executing AdMob. It includes INTERNET and ACCESS_NETWORK_STATE.
1. Add the following permissions (Before application Tag) to Manifest.xml
You have to add a meta tag that tells you are using the version of google play. Add the following meta tag before closing the application tag.
4. Save your Manifest File.
Step 5: Configure Admob Views in XML layoutAssume your main layout file is ad_test.xml (Displaying Ads in this layout) you must implement an xmlns to your main layout it might be relative or linear.
You are done!
Step 6: Make Visible your Ads, and Test it on your Emulator, DeviceOpen your Main Activity File (example: MyAds.java)
Warning : I recommend test mode of AdMob when you try the above activity. How to use Test Mode in Admob ?
You might know Google is very strict for preventing fraud clicks against ads they publish through various program like adsense, admob etc. Invalid impressions of Admob ads may cause your account instantly. You can use test mode by modifying the above code.
You can capture it from your logcat when you test it on your emulator.