ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
498 stars 212 forks source link

problem with banner when using a camera preview #123

Open maciejswis opened 6 years ago

maciejswis commented 6 years ago

Hi, We are using your plugin and all works pretty well. Unfortunately we encounter a problem, once one would start the camera - using the cordova-plugin-camera-preview plugin - the banner is not shown any more. The scenario is: we have a banner on one page (home), and user can go to other page with camera preview, after he comes back to home page banner is gone. It is working correctly for other pages. In home page we are calling on init

admob.banner.prepare()
    .then(function () {
        return admob.banner.show();
    });

and on destroy return admob.banner.remove(); There are no errors in console during debugging. What I can see is crash (error) report from google play console:

java.lang.IllegalStateException:
  at android.view.ViewGroup.addViewInner (ViewGroup.java:4471)
  at android.view.ViewGroup.addView (ViewGroup.java:4312)
  at android.view.ViewGroup.addView (ViewGroup.java:4252)
  at android.view.ViewGroup.addView (ViewGroup.java:4225)
  at name.ratson.cordova.admob.banner.BannerExecutor$4.run (BannerExecutor.java:214)
  at android.os.Handler.handleCallback (Handler.java:761)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:156)
  at android.app.ActivityThread.main (ActivityThread.java:6523)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832)

$ cordova platform list

cordova-admob-sdk 0.11.1 "AdMob SDK" cordova-plugin-admob-free 0.11.0 "Cordova AdMob Plugin" cordova-plugin-camera-preview 0.9.0 "cordova-plugin-camera-preview" . . .

$ cordova --version 7.1.0

BTW When I change configuration and set overlap: true problem disappears, but that is not what I need - I would like to have turned off deliberately.

ratson commented 6 years ago

Thanks for reporting this. Looks like you have a special use case, I don't have time to implement it, feel free to send a PR to improve it.

inicklas commented 6 years ago

Thanx for this plugin sir!.

@maciejswis if you still need a way around this issue, you can try setting toBack to false in CameraPreviewOptions.

maciejswis commented 6 years ago

Thanks for hint @inicklas, unfortunately in our case we want to use toBack with true.

Anyhow thanks.

DaAlex90 commented 4 years ago

same for us too, thanks @maciejswis for pointing it out we might replace admob banner by something else..