Introduction
Ad-mob is a mobile advertising company. It gives advertisement opportunities for mobile applications and generates revenue to the developer, as the maximum number of free mobile apps is running Ad-mob advertisements and making money. Ad-mob supports both Android and iOS applications.
Ad-mob provides different types of advertisement units in our platform:
-
Banner Ad
-
Interstitial Ad
-
Rewarded Ad
-
Native advanced Ad
By reading this article, you will learn how to integrate Ad-mob banner ads in Android applications.
Prerequisites
-
Android Studio (Updated version)
-
Ad-mob account
-
Browser
-
Virtual or physical Android device
-
Stable internet connection
-
Data cable (If you're using a physical Android device).
We are moving with three stages to integrate ads in our applications, each stage contains the following steps:
-
Creating Ad-unit in Ad-mob portal
-
Developing Android Application and integrate Ad-mob ad
-
Testing our application
Creating Ad-unit in Ad-mob portal
Step 1
Login to Ad-mob using your Google account.
Step 2
After logging in, the home page will be opened. Now we can add a new app for creating an advertisement unit. Click “Apps” from the left side pane and then click “Add APP”.

Step 3
On the next page, click the “No” option if our application is not published in App markets.

Step 4
Next, fill in your application name, platform in the given field and then click the “Add” button.

Step 5
Now our application is added in Ad-mob and an app id will be created and displayed on that page. Next, we create an “Ad unit” in our application. Copy the App id in any text editors.

Step 6
In the AD unit page, click the “Select” option under “Banner Ad”.

Step 7
In the Ad configuration page, click the “Advanced Settings” option.

Step 8
Fill the given fields, Ad unit name, Ad type and automatic refresh options and then click the “Create Ad unit” button.

Step 9
On the next page, our Ad unit is successfully created and our APP id and AD UNIT ID will be generated in Ad-mob platform. Click the “Done” button to view our Ad units.

Step 10
Our Ad unit name is displayed and it's listed in the created application name part. Details are displayed at the left side pane.

Developing Android Applications and Integrating Ad-mob Ads
Step 1
Create a new Android application project. In my previous article, I demonstrated how to create an Android application project in Android studio. Click to read
Step 2
Next, connect our Android application with firebase. Click “Tools” -> “firebase” from the top of the menu bar.

Step 3
After clicking the firebase option, assistant pane opens on the right side of the Android studio. In the assistance pane choose “Ad-mob” and then click the “Add a banner ad to your app”.

Step 4
Click the “Connect to firebase” button. Connect to the firebase window will be opened.
Step 5
Give application project name and location and then click the “connect to firebase” button.
Our application connects within a few minutes.
Step 6
After successfully connecting, click the “Add Ad-Mob to your app” button to add dependencies to our application. Now Android studio syncs the newly-added dependencies in our application.
Step 7
Next, we are writing the code, in the left side project directory pane choose app -> manifests-> open “AndroidManifest.xml” file and then add an internet permission to our application.
Copy and paste the below code:








Dipa MehtaPosted Mar 9, 2020, 8:26 AM
Nice article Naveen, on Android app integration.