Hi Cuong,
Thank you for reaching out to us.
For us to further check the crashes happening in your banner ads, can you provide us the following information below privately? You can provide the following details via reply privately to author option or directly provide it to the link below.
If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:
1. Navigate to
2. Fill out all fields, and attach your file(s).
3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.
Regards,
|
||||||
|
||||||
--
---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/OjTZ0000000000000000000000000000000000000000000000RNNTBS00Kb9uNTEfSWe9PhlPdKMVjA%40sfdc.net.
Hi اسلام محمد,
Do you have any concerns related to Mobile Ads SDK? If so, please provide us the details. We'll be happy to assist you.
On the other hand, I've deleted your post as it contains private information. Below is the copy of your post with scrubbed information.
Regards,
|
||||||
+xxxxxxxxxxx
Mobile Ads SDK Team |
cachedAdView
is already attached to a parent view, and you need to remove it from that parent before re-adding it to the new FrameLayout
.Hi Andrey,
I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.
Hi Andrey,
Can you provide the code which caused this error?
The error "The specified child already has a parent. You must call removeView() on the child's parent first." Implies the cause of this bug is not internal to the Google Mobile Ads SDK, but from irregular view hierarchy.
|
Hi Andrey,
I think the problem is in your use of caching. Can you try a simpler implementation? For instance:
@Composable fun BannerAd(adSize: AdSize, adRequest: AdRequest, adUnitId: String, modifier: Modifier) { // Remember the adView so we can dispose of it later. var adView by remember { mutableStateOf<AdView?>(null) } if (LocalInspectionMode.current) { Box( modifier = Modifier.background(Color.Gray) .width(adSize.width.dp) .height(adSize.height.dp) ) { Text(text = "Google Mobile Ads Preview Banner.", modifier.align(Alignment.Center)) } return } AndroidView( modifier = modifier.fillMaxWidth(), factory = { context -> AdView(context).apply { // Make sure we only run this code block once and in non-preview mode. if (adView != null) { return@apply } adView = this this.adUnitId = adUnitId this.setAdSize(adSize) this.adListener = ... this.loadAd(adRequest) } }, ) // Clean up the AdView after use. DisposableEffect(Unit) { onDispose { adView?.destroy() } } }
Hi Cuong,
Maybe we can try changing how we remove the adview from the parent. In the case we are using some sort of dynamic or recycled view, the parent might change.
ViewGroup viewParent = (ViewGroup) adView.getParent(); viewParent.removeView(adView);