Latest Update: Add AdMob with Google Play Service
AdMob released AdMob sdk v6.0.1 for android a few days ago. It is compatible with my last AdMob tutorial, but I think it is better to create a new tutorial to show how to add AdMob ads to our android apps. In this tutorial, I am using:

  • Eclipse SDK Version: 3.7.2
  • ADT 18.0
  • Android SDK r18
  • AdMob v6.0.1 for Android
  • HTC Desire with 2.3.7

First, we go to the AdMob SDK download page to get the latest Admob v6.0.1 for android. Unzip the AdMob SDK package and copy AdMob SDK jar to our AdMob project folder.

AdMob SDK v6.0 Folder Structure
AdMob SDK v6.0 Folder Structure

Second, go to project properties window, add AdMob jar to Java build path.

Add AdMob SDK to Java Build Path
Add AdMob SDK to Java Build Path

Third, declare and add networking permissions INTERNET and ACCESS_NETWORK_STATE in project’s AndroidManifest.xml. AndroidManifest.xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
	<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".AdmobExample"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
		<activity android:name=""
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Fourth, add AdView instance in our app’s Activity:

package com.jms.AdmobExample;

import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;


public class AdmobExample extends Activity {
    /** Called when the activity is first created. */
	private AdView myAdView;
    public void onCreate(Bundle savedInstanceState) {

        myAdView = new AdView(this, AdSize.BANNER, "Your Publish ID");
        //get layoutView
        LinearLayout rootView = (LinearLayout)this.findViewById(;
        LinearLayout.LayoutParams layoutParams = new LayoutParams(480, 75);
        rootView.addView(myAdView, 0, layoutParams);        
        AdRequest re = new AdRequest();

Solution for Error: String types not allowed at configChanges

Some friends meet the following error when running my example source code. The problem of this error is that Google AdMob Ads SDK for Andoird requires at least Android 1.5 and we must compiling the app target to Android v3.2 or API Level 13.

error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|

Build App Targeting to Android 3.2 API Level 13
Build App Targeting to Android 3.2 API Level 13

When you want to make your app compatible with version earlier than Android 3.2, you can set the “android:minSdkVersion” attribute in the AndroidManifest.xml file.

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

Try AdMob example apk here.
Try source code here.

Previous PostNext Post


  1. manifest file shows followin error

    error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|screenLayout|uiMode|

    what to do ?

  2. Hi raman,

    First, please make sure that you are using the latest google android sdk, and ADT. And also make sure the your AdMob is the latest version.

Leave a Reply

Your email address will not be published. Required fields are marked *