EddyVerbruggen / nativescript-admob

NativeScript plugin to earn some precious :moneybag::moneybag: with ads by Google AdMob
MIT License
69 stars 26 forks source link

App crash when going back: The specified child already has a parent. You must call removeView() on the child's parent first. #79

Closed MrSnoozles closed 4 years ago

MrSnoozles commented 4 years ago

Hello,

just wanted to report a bug I encountered that has to do with this plugin.

When I'm on a page where an Admob banner is displayed, go to another page and then back to the Admob-page the app crashes with the following error:

The specified child already has a parent. You must call removeView() on the child's parent first.

I wanted position the banner on a custom position so I embedded a Frame on the page that displays a page with the banner. My page layout looks like this:

<Page>
   ..Content Content Content..

   <StackLayout height="120">
        <Frame>
            <!-- ADMOB Banner is created here: -->
            <Page @pageLoad="loadAdmobBanner"></Page>
        </Frame>
    </StackLayout>

   ..Content Content Content..
</Page>

Now the app only crashes if the banner has already been loaded on the page. If I don't call admob.createBanner() in the function 'loadAdmobBanner' the app does not crash.

Is there a possible workaround for this?

MrSnoozles commented 4 years ago

Seems to be fixed with NativeScript 6.5.0 https://github.com/NativeScript/NativeScript/releases