Skip to main content

Installing Google AdMob into Android Apps

Previously I wrote on why ads are needed to help maintaining an app. Read the article here

---This is quite an old article. You may find the latest supporting AdMob 6.x in here ---

This is quite a long tutorial, there are 3 major steps involved. The experiment is done using Windows 7, Eclipse Helios and AdMob SDK 4.1.0 (which currently is the latest-during time of writing).

STEP 1: Get the ads from

To display the AdMob ads in your Android mobile apps, you need to register first at the . After completing the registration, login and Add Site/App. Refer to Figure 1.


Figure 1

Choose the desired platform and fill in the details (as in Figure 2). Just put http:// in the Android Package URL if your app is not published in the market yet. And click Continue.

ScreenHunter_16 May. 16 08.35

Figure 2

Download the AdMob Android SDK, and save the zip file in your machine. Make sure to extract the file and save it to your hard disk (anywhere is possible).

ScreenHunter_17 May. 16 08.36

Figure 3

STEP 2: Install the AdMob SDK into your Android project.

The most important file in the AdMob Android SDK that you download is GoogleAdMobAdsSdk-4.1.0.jar . Currently it’s in version 4.1.0 .

ScreenHunter_18 May. 16 08.40

Figure 4

Go to your project folder (in Eclipse), and right click to your project (Figure 5). Choose Properties.


Figure 5

Click the Java Build Path on your left. Choose the Libraries in the tab, and click Add External JARs. Locate the JAR file (GoogleAdMobAdsSdk-4.1.0.jar). And click OK.


Figure 6


Figure 7


Figure 8

STEP 3: The codes to display ads in your app.

Add some additional activity and permissions in the manifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Calc"
<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"/>
<uses-sdk android:minSdkVersion="4" />


Create attr.xml file in the res/values 



Related links

  1. Official Documentation (which is not updated timely) -
  2. Official Discussion (AdMob SDK 4.0.10) -
  3. A very good tutorial for AdMob SDK 4.0.4 -


  1. I think that attrs.xml file is not used anymore in version 4.1.0, so it's not needed. Also setTesting method is being deprecated.

  2. Dear Anonymous,
    Thanks for the comment. I'll check and update this post later...

  3. So far the hands-on provided here is working...

  4. Hi,
    Can you take a look at the following question from ?

    I seem to get this behavior ONLY when i load the AdView in my activity. Even an empty Activity with just the AdView widget takes tons of memory and I see with HPROF that what's keeping it from being released is that the InputMethodManager holds a reference to it (Which I didn't add anywhere...)

  5. Another related question on the same memory issue:

  6. I've added the code and i'm not getting any add..
    I've changed ads:adUnitId="YOUR_PUBLISHER_ID_HERE" for ads:adUnitId="xxxxxxxxxxxxx" the x's stand for the Publisher Id.
    After waiting 4 minutes on my phone im not getting any ads?

  7. Dear Christian,

    Maybe you could share with me the project folder, I'll check it for you.
    Email me at khirulnizam[a]

  8. I found that it's not working in the emulator. You need to test the admob ads in a real Android phone.

  9. Try to add: adRequest.addTestDevice("314321C010A54CE800467089A3E155E6");
    Look for this code in LogCat while you start the app.

  10. salam kenal sob, info: buat rekan2 yang ingin pasang mobgold/admob dengan java script di halaman html silahkan kunjungi terimakasih

  11. make sure to setTesting() to false, when you deploy the apps...

    AdView adview = (AdView)findViewById(;
    AdRequest re = new AdRequest();
    re.setTesting(false);//this must be false when apps is released in the market

  12. Can you tell me how to put an ads banner in the preview screen for a live wallpaper?As in the Fireflies live wallpaper (, I don't know how to put an ads banner in the Preview screen (not Settings screen).

    When I install the Fireflies wallpaper on my HTC which is on Android 2.2.1 the banner shows up in both Preview and Settings screens, but on my two other Sony Ericsson (on 2.3.3) I can only see the banner in the Setting screens. Does that have something to do with Sony Ericsson or the version of Android?


  13. My app is telling me I need to have AdActivity declared in AndroidManifest with configChanges. but added the lines:

    Any clue what is wrong?

  14. ok so I found out that eclipse wants me to change to android:configChanges="keyboard|keyboardHidden|orientation|screenlayout|uiMode|screenSize|smallestScreenSize"/> but when I do this, it says string types not allowed.

  15. Refer to this post for AdMob SDK 6.x
    All the best...

    1. I have added this sample code to my app and it work perfect on my device, I saw my first admob ads for a brief moment in fact how many times evry time I run the app on my device but when it goes to the next activity it will not display the next screen and would totally kills the whole app. it say it stopped unexpectedly. can you help me. thanks.

  16. also in addition i saw my admob status and shows that my app is sending my request. hence the code work but am i missing something an ondistroy or any class that would display the next activity I mean it totally just wont go to the next acctivity it displays the first screen with my admob insert running and it just crash evrytime it goes to the next screen. again thanks.

  17. also in addition i saw my admob status and shows that my app is sending my request. hence the code work but am i missing something an ondistroy or any class that would display the next activity I mean it totally just wont go to the next acctivity it displays the first screen with my admob insert running and it just crash evrytime it goes to the next screen. again thanks.

  18. sorry to add this again anyway, I have a fatal error: NoAPI database founf in null comment in my error log. I guess thats what it starts but how come it works when I dont have the admob insert. do I have to include something before going to the next activity. again sir thanks a million to your help.

    1. It's difficult for me to debug the error without having to look at the source code and the error message personally...

    2. Wondering whether you install AdMob 4.x or AdMob 6.x...


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

Enabling Intel Virtual Technology in LENOVO G50 - 80 BIOS setting

Turn off the laptop, and search for a SECRET BUTTON on the left side. Wait for the Lenovo logo to finish, and Choose BIOS setting. Go to CONFIGURATION tab, and you will see INTEL VIRTUAL TECHNOLOGY. Press ENTER on the VIRTUAL TECHNOLOGY option, and choose ENABLE. Fn+F10 to SAVE configuration and RESTART.

Contact Us at

Powered by EMF HTML Contact Form

The Challenges of Handling Proverbs in Malay-English Machine Translation – a research paper

*This paper was presented in the 14th International Conference on Translation 2013 ( ). 27 – 29 August 2013, Universiti Sains Malaysia, Penang. The PDF version is here: The test data is here: Khirulnizam Abd Rahman, Faculty of Information Science & Technology, KUIS Abstract: Proverb is a unique feature of Malay language in which a message or advice is not communicated indirectly through metaphoric phrases. However, the use of proverb will cause confusion or misinterpretation if one does not familiar with the phrases since they cannot be translated literally. This paper will discuss the process of automated filtering of Malay proverb in Malay text. The next process is translation. In machine translatio

Most used STRING functions in my PHP coding

These are my favourite string manipulation functions in my daily coding life. Dedicated especially to Web Programming students. Read them and have fun. Expect a happiness after a storm , and you’ll find your “inner peace”… This post is still in draft. I’ll update and refine with more examples that I’ve personally develop. More after the break…