I am brand-new to Cordova and mobile app development. I am following the instructions for the plugin admob-plus-cordova, to show a BANNER AD, here:
The deviceready async event listener is firing, and all code before await admob.start()
runs successfully, but not the console.log('AdMob started.')
. I have done all I could see in the documentation, but admon-start() does not complete in order to do show the ad.
mavenCentral()
and google()
are loaded in my repositories.gradle file (the plugin also does this).await.admob.start()
promise. It does not execute the catch either - no output in the console when doing conbsole.log(e).<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:excludeFromRecents="true" android:name="com.google.android.gms.ads.AdActivity" android:noHistory="true" />
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-mypublisher~informationhere" />
<meta-data android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT" android:value="true" />
let banner
document.addEventListener('deviceready', async () => {
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version + '. Starting AdMob');
document.getElementById('deviceready').classList.add('ready');
await admob.start().then(() => {
console.log('AdMob started.');
}).catch(e => console.log(e));
banner = new admob.BannerAd({
adUnitId: 'ca-app-pub-3940256099942544/6300978111', // THIS IS A GOOGLE TEST AD
position: 'top'
})
banner.config({
marginTop: 10,
marginBottom: 5,
backgroundColor: 'black'
})
banner.on('impression', async (evt) => {
await banner.hide()
})
await banner.show()
console.log('Showing ad.')
}, false)
I can't help but think that I need to create a container for my app within my HTML file, but I am not finding anything indicating this while doing a Google search. As it stands, I am expecting to see "AdMob started." after the call the admob.start()
.
Any ideas?
A friend offline of Stack Overflow showed me about chrome://inspect (apparently, it is not the same as the normal inspector when working with Cordova - I do not know why). It showed me an error which is not present in the normal code inspector. After resolving that error, the issue was resolved.