admob-plus: Ads are not shown

Ads are not showing using this plugin. Let me describe the steps I followed from scratch, maybe you can assist me. First, I created a new cordova project: cordova create AdmobProject cd AdmobProject

Then, I add the plugin cordova plugin add admob-plus-cordova --save --variable APP_ID_ANDROID=ca-app-pub-3940256099942544~3347511713

I got this ID from Google website. Then, I modify the index.html inside AdmobProject/www folder. I leave it like this:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
    <meta name="color-scheme" content="light dark">
    <link rel="stylesheet" href="css/index.css">
    <title>Joputa</title>
</head>
<body>
    <script src="cordova.js"></script>
</body>
</html>

And now I follow the instructions from plugin website and add the instructions for the banner. The index.html file is now:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
    <meta name="color-scheme" content="light dark">
    <link rel="stylesheet" href="css/index.css">
    <title>Joputa</title>
</head>
<body>
    <script src="cordova.js"></script>
    <script>
        let banner
        document.addEventListener('deviceready', async () => {
            banner = new admob.BannerAd({
                adUnitId: 'ca-app-pub-3940256099942544/6300978111',
            })
            banner.on('impression', async (evt) => {
                await banner.hide()
            })
            await banner.show()
        }, false)
    </script>
</body>
</html>

I entered the test unitAdId provided by plugin website. When I add android platform and build using cordova, the app does not display anything at all. Suggestions about how to fix this, please?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

i think i found the problem… you need to add: <preference name="GradlePluginKotlinEnabled" value="true" /> to config.xml for the new admob-plus 2.x versions … following this https://admob-plus.github.io/docs/cordova/upgrade let me know if its working for you 😃