How To Earn Money Using Google AdMob With Android Application

Introduction

 
One of the hottest discussion points in Android technology is how to earn money using Android applications. In this case, ‘AdMob’ of Google is the best platform for the applications for monetization and maximizing the revenue. Over 1 million apps are using ’AdMob’ to generate reliable revenue with more than $1 billion paid to the developers.
 
In this article, I am going to illustrate the steps of how you can display ads in your application to earn money.
 
Step 1
 
First of all, you have to sign up for AdMob by visiting the URL - https://www.google.com/admob/#subid=usenetdac
 
Android
 
Step 2
 
Create AdMob account by providing – Country Name, Timezone, and billing currency, and also, accept the terms and conditions. Then, click on "Create AdMob Account."
 
Android
 
Step 3
 
Let Google know your suggestions and inform you of updates. To verify your Gmail account.
 
Android
 
Step 4
 
Verify your account and contacts, then continue to ‘AdMob’ account.
 
Step 5
 
Now, move to your dashboard and click on Apps > Add your First App by giving your application name. Here, you have to select your project status too, i.e., whether you have published your app or not. Now, choose the app platform - either Android or iOS.
 
Step 6
 
Now, you have to create an ad unit by selecting your project and clicking on the ‘ADD AD UNIT’ button.
 
Step 7
 
Choose your ad type from below.
 
Android
 
There are three categories of Google Advertisement Banner (like a ribbon), Interstitial (full screen), and Rewarded (videos). Here, I am going to illustrate by selecting the Banner Ads.
 
Step 8
 
While selecting the Banner type, you have to create an ad unit for this particular project by giving the ad unit name.
 
Android
 
Step 9
 
Finally, you have to set up the payments by submitting your addresses, etc. and all. You are done with the AdMob configuration for your app
 
Step 10
 
Now, you have to integrate your app with App id and Unit id in the following way.
 
Create an app first –In this example, I am using Android Studio 3.0.1 with Kotlin. See my article Getting started with Android and Kotlin if you want to use a lower version of Android Studio for Kotlin development.
 
Create a New Project, give the name and location of the project, select the ‘Phone and Tablet’ app category. Set the minimum SDK 19, click "Next". Select an empty Activity > Next > Finish.
 
Step 11
 
Make your project ready as below –
project.gradle file – add the following maven if not exist in this file.
  1. allprojects {  
  2.     repositories {  
  3.         google()  
  4.         jcenter()  
  5.         maven {  
  6.             url "https://maven.google.com"  
  7.         }  
  8.     }  
  9. }  
  10. build.gradle(Module :app)  
Add the following dependency in this file -
implementation 'com.google.android.gms:playservicesads:11.6.0'
 
Step 12
 
Add the following XML code to your activity_main.xml file.
  1.  <android.support.constraint.ConstraintLayout   
  2.     xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     xmlns:app="http://schemas.android.com/apk/resauto"  
  4.     xmlns:tools="http://schemas.android.com/tools"  
  5.     xmlns:ads="http://schemas.android.com/apk/resauto"  
  6.     android:layout_width="match_parent"  
  7.     android:layout_height="match_parent"  
  8.     tools:context="manigautam.app.newtestingapplication.MainActivity"  
  9.     >  
  10. <com.google.android.gms.ads.AdView  
  11.     android:id="@+id/topicaddview"  
  12.     android:layout_width="wrap_content"  
  13.     android:layout_height="wrap_content"  
  14.     ads:adSize="BANNER"  
  15.     app:layout_constraintBottom_toBottomOf="parent"  
  16.    ads:adUnitId="caapppub8744339993361257/7857148840"  
  17.     >  
  18. </com.google.android.gms.ads.AdView>  
  19.   
  20. </android.support.constraint.ConstraintLayout>  
Here, ‘adUnitId=” caapppub8744339993361257/7857148840” is the default unit id provided by AdMob for testing purpose. You can use your Ad Unit Id here.
Step 13
 
Add the following Kotlin code to your MainActivity.kt file.
  1. import android.os.Bundle  
  2. import com.google.android.gms.ads.AdRequest  
  3. import com.google.android.gms.ads.AdView  
  4.   
  5. class MainActivity : AppCompatActivity() {  
  6.   
  7.     override fun onCreate(savedInstanceState: Bundle?) {  
  8.         super.onCreate(savedInstanceState)  
  9.         setContentView(R.layout.activity_main)  
  10.         var addview: AdView =findViewById(R.id.myaddview)  
  11. //finding view          
  12. var addRequest: AdRequest = AdRequest.Builder()  
  13. .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build()  
  14. //initializing AdRequest  
  15.         addview.loadAd(addRequest)  
  16. //load view with AdMob.  
  17.   
  18.     }  
  19. }  
Step 14
 
Add the internet permission to AndroidManifest.xml.
  1. <usespermission android:name="android.permission.INTERNET"/>  
Step 15
 
All done! Now, you can build and run your app for output.
 
Android
 

Summary

 
Congratulations!! You can see at the bottom of the app, there is a sample advertisement.


Similar Articles