Latest Update: Add AdMob with Google Play Service
Last time, I released a post for “Add Google Admob in Android Application“. And I got a feedback today about this admob android tutorial. The example code and that demo application doesn’t work any more. Then I checked my Admob account and found out that app’s Status is red, which mean my app is inactive. If the app works well, the status color should be green. And some of my apps status also show green color with exclamation mark, which means my app is idle (Your site was previously active but has not sent an ad request in the previous 72 hours).
Why My Admob APP Status is Inactive?
Currently, I only met this admob inactive problem twice. The first time is when I created a new app in the Admob. And this is the second time. Some friends ask me that they create a new Admob app. They can see the ads in the Android emulator with that publish id. And the app can also shows ads in their test phone as well. But in the Admob report, the status is still red (inactive). I think this is because that you might call adRequestset.Testing(true) or adRequestset.setTestDevices(“textdevice”) in your apps. And the admob also takes time to update their status. So for new app in Admob, you don’t need to worry if your app can show the ads
But my problem is here. My app worked well before. And I published it on my site to provide people to download and test. And it suddenly became inactive and the app also didn’t show the app. I didn’t get any notification about it and there is no farther information to let me know what happened there. So I guess the reason is that I also provide the source code downloading and I remain my publish id in the source code by mistake. Many friends downloaded my source code and tried it. This may cause some invalid clicks which may violet Google policy. And eventually my publish id in admob become inactive.
Add Google Admob in Android Application With SDK 4.3.1
Since I used Admob SDK 4.0.4 in my previous example, and it is not recommended for current Admob. And that example also doesn’t work for the latest android sdk r18 and adt 18. So I will post the latest example to show you how to add Google Admob in Android application with Admob SDK 4.3.1 and Android SDK r18. For the code example, you can check source code in Admob Offical Site Tutorial. Here I will tell you why it doesn’t work when you follow that instructions.
Could not find class ‘com.google.ads.AdView’ Error
After you update the Android SDK to r17 or r18 and it will force you to update the ADT plugin for Eclipse to ADT 17.0.0 or ADT 18.0.0. With these update, you will meet several problems:
Adview can not be resolved to a type
Adrequest can not be resolved to a type
Adview can not be resolved to a variable
The solution for this problem is create a folder “libs” under your project, and moving your Admob SDK jar to “libs” folder.
Will Admob SDK 4.3.1 work in Android 2.3 (less than Android v3.2 or android-13)
Yes. It will. The Admob SDK 4.3.1 for Android requires you to compile your Android application against at least Android v3.2. If you want to make your application to be compatible to lower version, Android 2.3 or Android 2.2 for example. You can just set your android:minSdkVersion to 9 or 8 in your AndroidManifest.xml file. Here is the example:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="13"/>