Close this search box.

How To Insert AdMob Native Ad In your Android App

In this article, I will show you how to insert Native Ad code in your Android Application.

But before that let me give you a brief idea about what is Native Ad.

Native Ad is one of the Ad types of AdMob which help you to generate revenue by displaying Ads on your App. To learn more about AdMob and Native Ad, click on the link provided below.

What is AdMob and how to generate Ad unit ID?

There are total four types of AdMob Ads through which you can earn money. You can click on the link below to learn more about other types of AdMob Ads.

  1.  Banner Ad
  2.  Native Ad
  3.  Rewarded Ad
  4.  Interstitial Ad

Native Ads can be inserted between ListView or CardView or any List item, at any place. It totally depends on you where you want to display the Native Ad in your application.

Now, let’s get started with how to place the code of Native Ad in your Android Application. I have assumed that you are using Android Studio for developing your app and your project is opened in it. Follow the below steps and copy paste the code into your project carefully.

⟩⟩  First of all, you need to add below line of code in your build.gradle dependencies file.

compile ''

⟩⟩  Then you need to add below line of code in your build.gradle (Project) dependencies file.

classpath ''

after adding the above codes you will get a sync now option at the top right corner of the page. Click on that and wait for a few minutes to complete the process, once the gradle building is finished you are ready to go with the next steps.

⟩⟩ Then open the Manifest file and add Internet permission to it.

<uses-permission android:name="android.permission.INTERNET" />

⟩⟩  In project structure, navigate to activity_main.xml and paste the following code in your layout.


and in the same file i.e activity_main.xml add below lines of code in the header part


⟩⟩  Now open and add below lines of code in public class

private static String LOG_TAG = "EXAMPLE";
NativeExpressAdView mAdView;
VideoController mVideoController;

⟩⟩  Then under and add below lines of code in onCreate() method.

// Locate the NativeExpressAdView.
mAdView = (NativeExpressAdView) findViewById(;

// Set its video options.
mAdView.setVideoOptions(new VideoOptions.Builder()

// The VideoController can be used to get lifecycle events and info about an ad's video
// asset. One will always be returned by getVideoController, even if the ad has no video
// asset.
mVideoController = mAdView.getVideoController();
mVideoController.setVideoLifecycleCallbacks(new VideoController.VideoLifecycleCallbacks() {
    public void onVideoEnd() {
        Log.d(LOG_TAG, "Video playback is finished.");

// Set an AdListener for the AdView, so the Activity can take action when an ad has finished
// loading.
mAdView.setAdListener(new AdListener() {
    public void onAdLoaded() {
        if (mVideoController.hasVideoContent()) {
            Log.d(LOG_TAG, "Received an ad that contains a video asset.");
        } else {
            Log.d(LOG_TAG, "Received an ad that does not contain a video asset.");

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

⟩⟩  Now open string.xml file in values folder and paste the below line of code.

<string name="ad_unit_id">ca-app-pub-39402560999xxxxx/21772xxxxx</string>

Native AdMob ID used here is a sample ID. In order to get revenue, you need to replace this test ID with your own Native Ad ID.

If you don’t know how to get your own Native Ad Id then click here how to get Native Ad Unit ID.

Note: Don’t use your real Ad Unit ID while testing and never click on your own Ads it is against AdMob Policy.

That’s it, friends, this is the correct and simple way to insert Native Ad in your Application. Just follow the above steps and copy paste the code carefully at the correct location mentioned above.

If you are a beginner you will love to learn Android Application development from scratch.

If you found this article helpful please do comment below and share the article to support me. If you have any suggestion please feel free to comment below.

Sign up for our Newsletter


Award winning hosting company for your website


Best page builder for creating a stunning website


The most popular theme among webmasters

We use cookies for essential website functions and to better understand how you use our site, so we can create the best possible experience for you ❤️

elegantespace logo png

How to insert AdMob Native Ad in your Android App (Write Your Opinion)