Make Money Online BANNERS How To Implement Banner Ads In Android Studio | How To Add Admob Banner Ads In Android Studio.

How To Implement Banner Ads In Android Studio | How To Add Admob Banner Ads In Android Studio.

How To Implement Banner Ads In Android Studio | How To Add Admob Banner Ads In Android Studio. post thumbnail image


Banner ads are a great way to monetize your Android app. They are unobtrusive, easy to implement, and can be customized to fit the look and feel of your app. In this article, we’ll show you how to add banner ads to your Android app using Google’s AdMob platform.

Before we get started, there are a few things you’ll need to do:

1. Create a Google AdMob account and generate a banner ad unit ID.
2. Download the Google Play services SDK.
3. Add the Google Play services SDK to your Android Studio project.

Creating a Banner Ad Unit ID

The first thing you’ll need to do is create a banner ad unit in your AdMob account. To do this, log into your account and click on the “Monetize new app” button.

Enter the name of your app and select “Banner” as the ad format. Choose a name for your ad unit and click on the “Create Ad Unit” button.

Once your ad unit has been created, you’ll be given an ID that looks something like this: ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN. This is the ID that you’ll need to use when adding banner ads to your app.

Adding the Google Play Services SDK

Now that you have an AdMob account and an ad unit ID, you can begin integrating banner ads into your Android app. The first thing you’ll need to do is download the Google Play services SDK from the Android developer website.

After downloading the SDK, launch Android Studio and open your project. Select “File > New > Import Module”. Choose the “google-play-services_lib” directory that you extracted from the ZIP file and click on the “Finish” button.

When prompted, select “Copy modules into project”. You should now see a new module in your project called “google-play-services_lib”.

Adding google-play-services_lib as a Dependency

Now that you’ve imported the google-play-services_lib module, you need to add it as a dependency for your app module. To do this, open up the build.gradle file for your app module and add google-play-services_lib as a dependency:

dependencies { compile ‘com.google.android.gms:play-services:4+’}

Now that you’ve added google-play-services_lib as a dependency, you can start adding banner ads to your app!

Adding Banner Ads to Your App

The first thing you need to do is add some code to inflate a BannerAd object in your activity’s onCreate() method:

@Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R .layout .main _activity); // Create an ad request . AdRequest adRequest = new AdRequest .Builder () .addTestDevice (AdRequest .DEVICE _ID _EMULATOR ) // All emulators // Add additional test devices as needed with // .addTestDevice(“ABCDEF012345”) .build (); // Loads the ad into memory so it’s ready when shown below MainActivityBannerActivity = (BannerAd) findViewById (R .id .adView ); MainActivityBannerActivity .loadAd (adRequest ); … } You’ll also need to add some XML code to define where in your activity’s layout file should be displayed:

Related Post