Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Add Google AdMob Ads in Android Application & Earn Money

Want to Earn Money from Android Application? Yes, than you are on right place to get accurate method to earn money via android application. AdMob is the best mobile advertising site/company to fill your pocket in dollars. Initially, i don't have any idea to earn money via android apps but now i know how can i earn money from my android applications that's why I am sharing this method and hope everyone like it.

In this Tutorial, we will learn how to show Google AdMob Ads on Android Application step by step. We will need the following two things:-

1. Ad Unit Id from Admob site.
2. Google Play Services installed in Android SDK.

How to get Ad Unit Id from Admob site:-

1. Go to Admob site.

2. Create New Account (if you are already an admob user, then log in). 

3. Select "Monetize new app" option.

Admob monetize new app

4. Search your app on Google play or fill details manually of your app to connect.

Form to add app on Admob site

5. After filling all information, you will get instruction to set up admob unit id.

7. Now you have added your app to admob site. Go to Monetize tab and check your added app in "all app" list and than select your added app and create new ad-unit. Create ad-unit for banner or Interstitial Ads as you want in your application and get Ad Unit id which will look like this: ca-app-pub-xxxx71439079xxxx/270233xxxx.

8. Now use Ad Unit Id in your project.

How to get Google Play Services Folder:-

1. Open android SDK -> Click on Windows -> android SDK manager -> extras -> download Google play services.

Add Google AdMob Ads in Android Application
Install Google Play Service Packages

After installing Google Play services, import it in your workspace as an android project. Now we have Admob Ad Unit Id and Google play services both. Create a new project to test Ads on android application and use Google play services as a library in your android project.

How to Add Google AdSense code in Android Application:-

1. Now select project -> right click on project -> properties -> android -> add library -> select Google play services folder -> Apply.

How to add Google AdMob Ads in Android Application
Add Google Play Services Package As a Library

2. Open your android XML file and add the following line in layout:


3. Add AdView in Layout:


4. The Android XML file will look like this:

<?xml version="1.0" encoding="utf-8"?>

5. Now open your Java file and initialize AdView Object in your Activity.

AdView ad=(AdView)findViewById(;

6. Load Ad from Google:

ad.loadAd(new AdRequest.Builder().build());

Now change AndroidManifest.xml file according to the code given in the end of the tutorial & run your project. Now install the application on your phone & check ads!

For Interstitial Ads:-

This Ad will be displayed on your complete phone screen.

1. Use the following code in your activity:

 InterstitialAd end_ad=new InterstitialAd(this);
end_ad.loadAd(new AdRequest.Builder().build());

2. Show Ad if loaded:


Now change AndroidManifest.xml file according to the code given in the end of the tutorial & run your project. Now install the application on your phone & check ads!

Now change AndroidManifest.xml file:

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

android:targetSdkVersion="18" />

<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


android:value="@integer/google_play_services_version" />

android:label="@string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

<!-- Activity required to show ad overlays. -->

Both above examples are used in the following Android applications: Helper+ & Namaz Guide

Mostly apps use Admob Ads in Listview and show Ads when Loaded. Initially, I was confused that how can I add Ads after successfully loading and finally I got success and felt it was very easy. I added AdView widget at bottom of the parent layout & set visibility gone and use Listview widget in whole layout. After setting up XML file, I used below code in Activity:-

ad.loadAd(new AdRequest.Builder().build());

ad.setAdListener(new AdListener() {
public void onAdLoaded() {

Related Tutorials:-

★ Display Time using Broadcast Receiver in Android

★ Check Battery level using Broadcast Receiver in Android

★ Display all Mobile Contacts in Android

★ Perform Action on any Hardware Button in Android

★ How to Add Facebook SDK in Android Application

This post first appeared on Coders Hub: Android Code Examples And Programming Tutorials, please read the originial post: here

Share the post

Add Google AdMob Ads in Android Application & Earn Money


Subscribe to Coders Hub: Android Code Examples And Programming Tutorials

Get updates delivered right to your inbox!

Thank you for your subscription