Skip to main content

Example: How-to Install Google AdMob 6.x into Android Apps

How to make money from your FREE Android App

Previously I have posted the step-by-step how-to related to AdMob SDK 4.x in your Android apps in this post . This time is the AdMob 6.0 SDK released just recently. There’s one think I don’t like about the tutorial in the official documentation, the example only demonstrate an app with only one widget, which is the AdView widget (read here if u’d like to know what I mean Practically that doesn’t happen, coz normally we have several other widgets in the screen.

//this is the simplified versions of the codes below.

1. Download and admob sdk - in libs folder. Set path to the external library

2. admob layout
ads:adUnitId="738a44d913034b9f" />

3. add control in Java src
//admob widget
private AdView adView;
adView = (AdView)findViewById(;
adView.loadAd(new AdRequest());

4. AndroidManifext.xml - add add this activity declaration inside <application></application>
<activity android:name=""

5. AndroidManifext.xml - additional permissions
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />

STEP 1: Register yourself as a user at . Login and create a site (read further at

If you do not have a new site, than add one.

admob in android appFig. 1

admob in android appFig. 2

Scroll down and fill-up your app information. Leave the Android package URL blank if you have not upload your app yet.

setting site in admobFig. 3

Opt for typical ad banner 350x50 – later we can change into smart_banner option. Change the refresh rate if you’d like to.

setting site in admobFig. 4

Check the Ad Network should you have the account for the ad provider.

setting site in admobFig. 5

Save it and you’ll get the next screen. Notice the mediation ID (or Publisher ID), this ID will be needed in the in the AdView widget later.

setting site in admob -publisher IDFig. 6

STEP 2: Download the AdMob SDK currently SDK 6.1.0 at

make money from your android appFig. 7

Extract the zip file downloaded and you will get a file named GoogleAdMobAdsSdk-6.1.0.jar.

make money from your android appFig. 8

You may copy the file to be pasted in the project folder later.


STEP 3: Add an External JAR (library) in the project.

In your Android project create another directory called libs in your project. Notice the name, it will be used later as the path to you additional XML scheme in the apps view. (more on creating a new Android project in Eclipse –>

Copy GoogleAdMobAdsSdk-6.1.0.jar into libs

Create the new folder libs by right-click on your project->New->Folder. Copy the GoogleAdMobAdsSdk-6.1.0.jar into the libs folder.

Adding an additional library

Click on the project you’re currently working, hit Project->Properties on the Eclipse menu. Click on the Java build path as in the Fig 9, and hit Add External JARs button.

adding admob on android appFig. 9

Locate the GoogleAdMobAdsSdk-6.1.0.jar file in the workspace/project/libs .

adding admob on android appFig. 10

And you’ll see the GoogleAdMobAdsSdk-6.1.0.jar in the libs folder, as in Fig 11.

imageFig 11


STEP 4: Additional details in the AndroidManifest.xml

Open your AndroidManifest.xml using the code editor, and add this lines to the <application> properties;

<activity android:name=""

You might be facing one error while adding the android:configChanges if you are setting the minTargetSDK lower than 13. Do not worry just change the target Build to API level 13.


Right click your project, and click Properties.

image Build target is not your minimum SDK. Setting this will utilise the API level 13 capabilities, without having to worry this app cannot run in lower version of the minTargetSDK .

Next, add these  <uses-permission>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

And the meta-data attributes;

<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />

And the complete AndroidManifest.xml;

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
android:versionName="1.07" >

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

android:label="@string/app_name" >
android:label="@string/app_name" >
<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"/>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />


STEP 5: Adding the AdView widget in the screen

For example, your app view (screen) is the res/layout/main.xml, open this in the code editor.

Add a TableRow (optional) in the existing layout as a place to contain the AdView widget.

   1: <TableRow
   2:     android:id="@+id/tableRow2"
   3:     android:layout_width="match_parent"
   4:     android:layout_height="wrap_content" >
   5:     <
   6:         xmlns:ads=""
   7:         android:id="@+id/ad"
   8:         android:layout_width="fill_parent"
   9:         android:layout_height="wrap_content"
  10:         ads:adSize="SMART_BANNER"
  11:         ads:adUnitId="738a44d913034b9f"
  12:         />    
  13: </TableRow>


  • Put the adMob XML schema in the AdView widget. notice the path apk/lib/ in line 6. APK is your app, LIB is the from the folder LIBS we jest created in the STEP 3 and COM.GOOGLE.ADS refering to the one of the component in the JAR file GoogleAdMobAdsSdk-6.1.0.jar .
  • ads:adSize="SMART_BANNER" in line 10 is referring to the banner size. During my testing on the tablet, this adSize is suitable because it does expand base on screen size.
  • Change to your publisher ID (or Mediation ID) in line 11.

And the complete main.xml file would be;

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:orientation="vertical" >

android:layout_height="wrap_content" >

android:layout_height="wrap_content" >

android:scrollbars="vertical" />


android:layout_height="wrap_content" >

android:drawableRight="@drawable/search" />

android:text="Kesan" />

android:text="Cadang" />


android:layout_height="match_parent" />



STEP 6: Adding the adView in the source code.

   1: public class PeribahasaActivity extends Activity implements OnClickListener{
   2:     protected EditText txtsearch;
   3:     protected Button btnocr, btnkamus, btnsearch,btncadang;
   4:     //protected Button btnpaste,btntaipinput;
   5:     protected WebView webview1;
   6:     protected String serverurl;
   7:     protected AdView adView;
   8:     /** Called when the activity is first created. */
   9:     @Override
  10:     public void onCreate(Bundle savedInstanceState) {
  11:         super.onCreate(savedInstanceState);
  12:         setContentView(R.layout.main);
  14:         //admob widget
  15:         adView = (AdView)findViewById(;
  16:         adView.loadAd(new AdRequest());

In your existing Activity class (where you wanna display the adMob), add the following lines; line 7, line 15 and 16.

Compile and run in your emulator.

admob in android app

Testing the app with AdMob – the application is available here -

peribahasa scanner @ Google Play

Or download the APK here and follow this tutorial to install the APK into your emulator –> .

Hopefully you get the idea. All the best for the experiment…


  1. Here another example, complete downloadable source code here

  2. You're the BEST person I've seen explainging this issue.
    After hours & hours of searching -even rereading google's docs multiple times- you gave me what works & nicely illustrated.
    I bookmarked this page on my mobile phone & PC :)
    Oh, by the way I want to mention that by now -Sep 2012- adMob requires to set your target SDK to 4.x instead of 3.2 > so update this article to give everyone what they need.
    This is the warning in Google:
    Warning: All new Android apps created after October 14, 2011 will require an AdMob SDK that was released on or after March 15, 2011. This corresponds to version 4.0.2+ for Android. If you downloaded the library from our official download site, then you're already set. Otherwise you may have an old version of the AdMob SDK that was released prior to March 15, 2011, and your new app will not receive any ad impressions until you update your SDK.

  3. in Banner gettin
    "You must have AdActivity decared in AndroidMainfest with Config Changes"
    bt i have already define AdActivity with ConfigChanges
    please help out to solve this prbs

  4. Great tutorial!
    Thank you very much.

  5. hi kerul im trying many time to ad admob ads but i have problim
    the code is correct but it sey cant found xml and pild bath is error
    can you help me for this please

    1. Thank you, just realised that error. Pls do this after you have installed the project to your eclipse

  6. Hii Khirulnizam Abd Rahman
    Great tutorial.

    Inactive: AdMob has never received an ad request for your site.



Post a Comment

Popular posts from this blog

Several English proverbs and the Malay pair

Or you could download here for the Malay proverbs app – English proverbs and the Malay pair Corpus Reference: Amir Muslim, 2009. Peribahasa dan ungkapan Inggeris-Melayu. DBP, Kuala Lumpur CTRL+F to search Proverbs in English Definition in English Similar Malay Proverbs Definition in Malay 1 Where there is a country, there are people. A country must have people. Ada air adalah ikan. Ada negeri adalah rakyatnya. 2 Dry bread at home is better than roast meat home's the best hujan emas di negeri orang,hujan batu di negeri sendiri Betapa baik pun tempat orang, baik lagi tempat sendiri. 3 There's no accounting for tastes We can't assume that every people have a same feel Kepala sama hitam hati lain-lain. Dalam kehidupan ini, setiap insan berbeza cara, kesukaan, perangai, tabia

WebDev PHP DEVELOPMENT TOOLS Download the XAMPP latest version from . This installation file contains the Apache web server, PHP 5 and 4 interpreter, and the MySQL 5 Community edition. - download latest version MozillaFireFox (OpenSource web browser firefox) – download latest version Google Chrome – fastest web browser on earcth – fast download chrome here TEACHING PLAN Download the teaching plan here for Web/Internet Programming ( download ) NOTES HTML references HTML Editor - Lab 1: HTML Basics - Lab 2: Responsive Design: Lab 3: HTML Forms Lab 4: HTML 5 Lab 5: Bootstrap for responsive Web -

Submit your blog address here

Create your own blog and send the address by submitting the comment of this article. Make sure to provide your full name, matrix and URL address of your blog. Refer to the picture below. Manual on developing a blog using and AdSense, download here … Download Windows Live Writer (a superb offline blog post editor)

Contact Us at

Powered by EMF HTML Contact Form

ASK kerul pls...

Ask me please, just click the button... Any question related to the web, PHP, database, internet, this blog, my papers, or anything. I'll answer to you as soon as I can, if related to my domain. If not I'll try to find out from Google and provide you a link that can help you solve a problem. Sincerely, kerul. ASK kerul pls...