capacitor-community / admob

Community plugin for using Google AdMob
MIT License
205 stars 67 forks source link

Not working with stencilJS #120

Closed BrunoUY closed 2 years ago

BrunoUY commented 2 years ago

Describe the bug When the app open it close immediately

To Reproduce Steps to reproduce the behavior: 1 create a stencil ionic pwa 2 added capacitor + android 3 followed all steps to install admob plugin 4 don´t add anything else, just the implementation, compile on android and install the app

rdlabo commented 2 years ago

Please check the error log of Android Studio. In most cases, it will indicate the reason why the application terminated. We don't know with all this information, but we don't think there's anything that won't work with StencilJS.

Thanks.

BrunoUY commented 2 years ago

Hi again,

I have tested it with a standard pwa ionic plus stenciljs

I only add the admob plugin

Steps I have done: 1 - I follow the steps described here adding to the mainactivity.java, androidmanifest.xml, string.xml 2 - Test on device and works fine 3 - Add the admob initialize to componentDidLoad() 4 - test on device, and doesn´t work

I'm new to capacitor, maybe I'm doing something wrong.

In the stencil app I add the admob.initialize as this: image

This is the correct way to do it?

Errors that I see when debugging on android studio:


2021-07-16 22:10:16.280 2360-2360/... E/pps.dogtrainin: Invalid ID 0x00000000. 2021-07-16 22:10:16.282 2360-2360/... E/pps.dogtrainin: Invalid ID 0x00000000. 2021-07-16 22:10:16.536 2360-2360/... E/pps.dogtrainin: Invalid ID 0x00000000. 2021-07-16 22:10:16.536 2360-2360/... E/pps.dogtrainin: Invalid ID 0x00000000. 2021-07-16 22:10:16.775 2360-2360/... E/Capacitor: Unable to read file at path public/plugins 2021-07-16 22:10:17.207 2360-2520/... E/Capacitor: Unable to open asset URL: http://localhost/build/p-33849e23.entry.js 2021-07-16 22:10:17.210 2360-2520/... E/Capacitor: Unable to open asset URL: http://localhost/build/p-33849e23.entry.js 2021-07-16 22:10:17.220 2360-2360/... E/Capacitor/Console: File: http://localhost/build/p-f4d894c7.js - Line 1 - Msg: TypeError: Failed to fetch dynamically imported module: http://localhost/build/p-33849e23.entry.js undefined 2021-07-16 22:10:17.221 2360-2360/... E/Capacitor/Console: File: http://localhost/build/p-f4d894c7.js - Line 1 - Msg: Uncaught (in promise) TypeError: Cannot read property 'isProxied' of undefined


How can I proceed?

distante commented 2 years ago

Hi, that doesn't sound like a problem with this plugin. We do not use any isProxied property.

BrunoUY commented 2 years ago

Hi, I returned to the project, and just to let you know, it's working with the following change.

the only way to make it work was with the function initialize without the async keyword

import { AdMob, /* AdMobBannerSize, */ BannerAdOptions, BannerAdPluginEvents, BannerAdPosition, BannerAdSize } from "@capacitor-community/admob";

function initialize (): void {
    //const { status } = await AdMob.trackingAuthorizationStatus();

    AdMob.initialize( {
        requestTrackingAuthorization: true,
        testingDevices: [
            '9e6082a86aeb4687a44bed553d524707',
            /* '2077ef9a63d2b398840261c8221a0c9b' */
        ],
        initializeForTesting: true,
    } );
    console.log( 'initialize' );
}

When I use the async keyword in front a blank page at the start of the app appear. If you want I can send the stencil project for a demo page, or for your review

distante commented 2 years ago

If you have a demo project we can link it here!

Thank you. I will close this issue for now. If it is not resolved, feel free to open it.