AdMob Free plugin does not show banner ads instead just closes the app on simulator

Hi, I have my first Ionic app in the google play store. I wanted to add Google ads, I used AdMob free plugin by doing below in my IOnic capacitor project:

**cordova plugin add cordova-plugin-admob-free --save **
npm install @ionic-native/admob-free --save

app.module.ts is also updated to import the plugin and provider etc.
import { AdMobFree } from ‘@ionic-native/admob-free/ngx’;
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },

Added this function in my home.ts file:

import { AdMobFree, AdMobFreeBannerConfig } from ‘@ionic-native/admob-free/ngx’;

export class HomePage {
constructor(public admob: AdMobFree) {}
showBanner() {

    let bannerConfig: AdMobFreeBannerConfig = {
        isTesting: true, // Remove in production
        autoShow: true



    this.admob.banner.prepare().then(() => {
        // success
    }).catch(e => console.log(e));



I call the function showBanner() on Button click in my home.html page in my app like below:

<button ion-button (click)=“showBanner()”>Show Banner

Initially the build failed saying the cordova.variables.gradle does not exist.
I ran npx cap update android.

I can see the cordova.variables.gradle file then.

When testing on simulator , the gradle build fails giving the error from
package does not exist. I read some articles and added the dependency implementation “androidx.annotation:annotation:1.1.0” in build.gradle of capacitor-cordova-androids-plugin and replaced the to import androidx.annotation.NonNull in
I have also updated the Admob app id in the AndroidMnaifest.xml file of the capacitor-cordova-androids-plugin. Now the gradle builds with no errors.

When running on the simulator, when I click on the button showBanner, my app just closes in the simulator.

Have I done something wrong, can some one pls guide me in setting up the AdMob free plugin for my app.

I have looked at almost all the AdMob related links in the forum, could not get a clue. Also I am new to this Ionic framework, so any help with this cordova plugin will be highly appreciated.

Thanks a lot!

Can someone pls help me on this.