Implementing Admob Ads Into Your Android App

In this tutorial, you will learn how to implement Google Admob Ads into your Android application. Admob Ads enables mobile application developers to maximize their monetization on Android by tapping into Google and AdMob’s vast combined pool of advertisers. In other words, this a way to make money with your Android Application. We will create a simple view that shows an Admob test ad in an XML graphical layout. So lets begin…

[alert-announce] This tutorial refers to the legacy Admob and may differ from the New Admob that have been launched on May 2013. [/alert-announce]


Sign up as an Admob Publisher here and download the Google Admob Ads SDK. Log in to your dashboard that shows your revenues and estimated earnings.

To create an ad for your application, click on the Add Site/App Button.

Admob Add Site or App

Fill in the required information. The Android Package URL is the package name for your application. Locate your package name in your AndroidManifest.xml.

To locate your Publisher ID, click on Manage Settings shown on the screenshot below.

Admob Manage Settings

Create a new project in Eclipse File > New > Android Application Project. Fill in the details and name your project AdmobTutorial.

Application Name : AdmobTutorial

Project Name : AdmobTutorial

Package Name : com.androidbegin.admobtutorial

Open your and paste the following code.

package com.androidbegin.admobtutorial;

import android.os.Bundle;

public class MainActivity extends Activity {

	public void onCreate(Bundle savedInstanceState) {
		// Get the view from activity_main.xml

Extract the downloaded Google Admob Ads SDK and insert into your libs folder.

Google SDK Libs

Next, insert GoogleAdMobAdsSdk-6.2.1.jar to your build path. To do that, right click on GoogleAdMobAdsSdk-6.2.1.jar > Build Path > Add to Build Path.

Next, create an XML graphical layout for your MainActivity. Go to res > layout > Right Click on layout > New > Android XML File

Name your new XML file activity_main.xml and paste the following code.



Insert in your Publisher ID into “MY_AD_UNIT_ID” and your TEST_DEVICE_ID.



Run your application and in your LogCat and type “ads” in the textbox provided to filter the errors. Locate the test device ID shown on the screenshot below.

Admob Test Device

In your AndroidManifest.xml, we need to declare an activity for Google ads and permissions to allow the application to access to the Internet and check network status. Open your AndroidManifest.xml and paste the following code.







Admob Tutorial ScreenShot

Source Code 

[purchase_link id=”7850″ text=”Purchase to Download Source Code” style=”button” color=”green”]

Latest comments

Премного благодарен)


Implementing Admob Ads Into Your Android App