Hey guys, I hope you are doing well. Today here we will learn how to add Ads to our app and earn well. You developed greater apps. The best way to earn money to monetize apps using Google Admob. If you are an Android developer and want to earn money online every month, Admob is the best platform.
Introduction of Google Admob
Admob is a mobile advertising company and the parent organization of Google. Google Admob is the biggest app monetization platform.
Google Admob provides 4 types of Ads
- Banner Ads
- Interstitial Ads
- Rewarded Interstitial Ads
- Native Ads
In this tutorial, we will cover banner ads and Interstitial ads.
1. Banner Ads:
Banner Ads is like a banner. We can custumize size of of banner ads and set Ads at anywhere in activity. Add banner ads in app. Please follow below simple steps.
Step 1.
- first Login with your Gmail account.
- Goto to this link.
- From the Apps option create App

- If your app is already in play store then select YES otherwise NO.

- Then provide app information and click ADD.

- Then you will get an App ID. Copy it. You will need it later.

- Now open your Android app project and paste this below code inside application section. Now paste your app id.
1 2 3 4 5 6 7 8 9 10 |
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation |screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="Add App Id here" /> |
- Then click on CREATE AD UNIT and you will find three ad types. Only Banner and Interstitial types will be used here.

- Select Banner type. Provide Ad unit name and click on CREATE AD UNIT.

- Copy Banner Ad unit id and save it .You will need it later.

- Now open your android app project and open activity_main.xml and paste below xml code.
1 2 3 4 5 6 7 8 9 10 |
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="BANNER" ads:adUnitId="here paste unit id"> </com.google.android.gms.ads.AdView> |
- Open MainActivity.java file and put below code. Here also put app Id.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
package com.simplifiedtutorials.testads; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.MobileAds; public class MainActivity extends AppCompatActivity { AdView mAdview; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_interview_question); MobileAds.initialize(this,"put app Id here"); AdView mAdview =(AdView)findViewById(R.id.adView); AdRequest adRequest =new AdRequest.Builder().build(); mAdview.loadAd(adRequest); } } |
You test your app. It will show ads.
2. Interstitial Ads:
Then again go back to Ad types and select Interstitial Ad type. Provide Ad unit name and select CREATE AD UNIT.

- Copy the Interstitial ad unit id and save it. You will need it later.

- Add below code in mainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
package com.simplifiedtutorials.testads; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import com.google.android.gms.ads.AdRequest; import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.InterstitialAd import com.google.android.gms.ads.MobileAds; public class MainActivity extends AppCompatActivity { private InterstitialAd mInterstitialAd; AdView mAdview; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_interview_question); //ads mInterstitialAd = new InterstitialAd(this); mInterstitialAd.setAdUnitId("Add Unit id here"); mInterstitialAd.loadAd(new AdRequest.Builder().build()); mInterstitialAd.show(); //banner ads MobileAds.initialize(this,"Add App id here"); mAdview =(AdView)findViewById(R.id.adView); AdRequest adRequest =new AdRequest.Builder().build(); mAdview.loadAd(adRequest); } } |
Now test your app. Ads will show. If you got any error and problem please comment below.
Get sir ji keep it up..