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

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)

Applications of Web 2.0

Web 2.0 describes the changing trends in the use of World Wide Web technology and web design that aim to enhance creativity , secure information sharing, collaboration and functionality of the web. Web 2.0 concepts have led to the development and evolution of web-based communities and hosted services , such as social-networking sites , video sharing sites , wikis , blogs . Find a website or web application that conform to the criteria of Web 2.0. Put the name of the application and the URL in the comment below. Please provide your full name and matrix number. Make sure the application you choose is not already chosen by your friend in the previous comment.

Kursus Ionic 2021

Kursus terbaharu IONIC-5 Pengenalan sepintas lalu pembangunan apps Ionic WhatsApp kami di Dapatkan tarikh kursus terkini di Kolej Komuniti Temerloh September 2020 ILP Selandar Ogos 2020 Berikut senarai tutorial yang sedang kami bangunkan; HARI 1 & 2 Pengenalan IONIC dan cara pasang dalam Windows10 (   ). Versi  PDF pengenalan & install IONIC Pasang plugin TypeSript (skrip utama dalam Ionic) dalam Sublime. Struktur asas Page dalam projek Ionic. Sharing intent kepada media sosial. Plugin Kamera dalam apps Ionic ( ) HARI 2 & 3 IONIC + FIREBASE Firebase Ionic CRUD – masukkan rekod baharu ( download slides ) Firebase Ionic CRUD – baca rekod dan senaraikan ( download slides ) Firebase Ionic CRUD – perbaharui dan pada rekod (download slides) Kod contoh lengkap S-CRUD IONIC+FIREBASE di Kita pasti biasa dengan pem

Bootstrap Template for PHP database system - MyCompanyHR

HTML without framework is dull. Doing hard-coded CSS and JS are quite difficult with no promising result on cross platform compatibility. So I decided to explore BootStrap as they said it is the most popular web framework. What is BootStrap? - Bootstrap is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first web sites. (   ) Available here - Why you need Flat-UI? Seems like a beautiful theme to make my site look professional. Anyway you could get variety of BootStrap theme out there, feel free to select here Flat-UI is from DesignModo - Web Programming MyCompanyHR – PHP & MySQL mini project (with Boostrap HTML framework) Template 1: Template for the Lab Exercise. This is a project sample of a staff record management system. It has the PHP structured co