react-native-admob-native-ads
react-native-admob-native-ads copied to clipboard
error while updating property 'mediaView' of a view managed by:RNGADNativeView null the specified child already has a parent. You must call removeView() on the child's parent first.
when second time open same page then show error- error while updating property 'mediaView' of a view managed by:RNGADNativeView null the specified child already has a parent. You must call removeView() on the child's parent first.
critical issue please reply fast
@deepakkumar089551 Share complete crash details from adb logcat. and it would be best if you can provide an example repository where i can test and fix it soon.
@ammarahm-ed Hi Ammar I think I'm having same problem please resolve my issue I have already created issue.
@rakeshp947 if you can provide an example that can reproduce the issue, i will look into fixing it.
@ammarahm-ed I already provided you the complete logs, please have a look - here To reproduce this error add a video ad in the flatlist and scroll very fast till the end, it will happen.
@ammarahm-ed Any update on this??
Did anyone find solution for this? I am currently getting the crash: "Exception com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'mediaview' of a view managed by: RNGADNativeView"
It's occuring very frequently for an high percentage of the app users.
any update?
work for me Add this code in node_modules/react-native-admob-native-ads/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobMediaView.java
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// Add this
if(this != null){
this.removeAllViews();
}
}
any update?
I generated a release version and installed it only on my phone, I did some tests and realized that the app crashes only when the ad is a video, when it renders an image, it works fine.
Using NativeMediaView of course, I can't show a capture or anything like that because this only happens in production, Mr. @luongminh2410dev solution didn't work for me, unfortunately!
Complete log:
Exception com.facebook.react.bridge.JSApplicationIllegalArgumentException: Error while updating property 'mediaview' of a view managed by: RNGADNativeView at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp (ViewManagersPropertyCache.java) at com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackViewManagerSetter.setProperty (ViewManagerPropertyUpdater.java) at com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps (ViewManagerPropertyUpdater.java) at com.facebook.react.uimanager.ViewManager.updateProperties at com.facebook.react.uimanager.NativeViewHierarchyManager.updateProperties (NativeViewHierarchyManager.java) at com.facebook.react.uimanager.UIViewOperationQueue$UpdatePropertiesOperation.execute (UIViewOperationQueue.java) at com.facebook.react.uimanager.UIViewOperationQueue$1.run (UIViewOperationQueue.java) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches (UIViewOperationQueue.java) at com.facebook.react.uimanager.UIViewOperationQueue.access$2600 (UIViewOperationQueue.java) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded (UIViewOperationQueue.java) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame (GuardedFrameCallback.java) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame (ReactChoreographer.java) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame (ChoreographerCompat.java) at android.view.Choreographer$CallbackRecord.run (Choreographer.java:970) at android.view.Choreographer.doCallbacks (Choreographer.java:796) at android.view.Choreographer.doFrame (Choreographer.java:727) at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:957) at android.os.Handler.handleCallback (Handler.java:938) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loop (Looper.java:250) at android.app.ActivityThread.main (ActivityThread.java:7851) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958) Caused by java.lang.reflect.InvocationTargetException: at java.lang.reflect.Method.invoke at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateViewProp (ViewManagersPropertyCache.java) Caused by java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner (ViewGroup.java:5235) at android.view.ViewGroup.addView (ViewGroup.java:5064) at android.view.ViewGroup.addView (ViewGroup.java:5036) at com.google.android.gms.ads.nonagon.ad.nativead.br.e (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:69) at com.google.android.gms.ads.nonagon.ad.nativead.br.d (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:2) at com.google.android.gms.ads.nonagon.ad.nativead.bp.run (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:254) at com.google.android.gms.ads.internal.util.future.c.execute (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:15) at com.google.android.gms.ads.internal.util.future.d.execute (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:3) at com.google.android.gms.ads.nonagon.ad.nativead.an.z (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:19) at com.google.android.gms.ads.nonagon.ad.nativead.an.y (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:28) at com.google.android.gms.ads.nonagon.ad.nativead.bn.bI (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:37) at com.google.android.gms.ads.internal.formats.client.l.bN (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:213) at m.aig.onTransact (:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:21) at android.os.Binder.transact (Binder.java:1052) at com.google.android.gms.internal.ads.zzatj.zzbh (zzatj.java) at com.google.android.gms.internal.ads.zzben.zzbw (zzben.java) at com.google.android.gms.ads.nativead.NativeAdView.setNativeAd (NativeAdView.java) at com.ammarahmed.rnadmob.nativeads.RNAdmobNativeView.setNativeAd (RNAdmobNativeView.java) at com.ammarahmed.rnadmob.nativeads.RNAdmobNativeViewManager.setMediaView
@lean098 Unfortunately, I encountered your same situation, but it worked for me I try to remove unfocused ads on the screen and when other ads show (which are videos), this avoids conflicts with the previous ads version:
- react-native: 0.71.3
- admob-native-ads: 0.6.0
My patch-package:
diff --git a/node_modules/react-native-admob-native-ads/android/build.gradle b/node_modules/react-native-admob-native-ads/android/build.gradle
index be307ad..c6a9c5b 100755
--- a/node_modules/react-native-admob-native-ads/android/build.gradle
+++ b/node_modules/react-native-admob-native-ads/android/build.gradle
@@ -55,7 +55,7 @@ dependencies {
implementation 'com.facebook.react:react-native:+'
implementation "com.google.android.gms:play-services-ads:${safeExtGet('googlePlayServicesAdsVersion', '20.+')}"
implementation 'com.android.support:support-annotations:28.0.0'
- implementation 'com.google.ads.mediation:facebook:6.+'
+ implementation 'com.google.ads.mediation:facebook:6.11.+'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
}
\ No newline at end of file
diff --git a/node_modules/react-native-admob-native-ads/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobMediaView.java b/node_modules/react-native-admob-native-ads/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobMediaView.java
index d489ecf..2254f61 100644
--- a/node_modules/react-native-admob-native-ads/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobMediaView.java
+++ b/node_modules/react-native-admob-native-ads/android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobMediaView.java
@@ -62,7 +62,9 @@ public class RNAdmobMediaView extends MediaView {
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
-
+ if(this != null){
+ this.removeAllViews();
+ }
}
@Override
diff --git a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
index 2f4724a..21d86e1 100644
--- a/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
+++ b/node_modules/react-native-admob-native-ads/ios/RNAdMobManager/RNAdMobUnifiedAdQueueWrapper.m
@@ -75,7 +75,7 @@ -(instancetype)initWithConfig:(NSDictionary *)config repo:(NSString *)repo{
//Set request options
if ([config objectForKey:@"adChoicesPlacement"]){
- [adPlacementOptions setPreferredAdChoicesPosition:((NSNumber *)[config objectForKey:@"adChoicesPlacement"]).intValue];
+ [adPlacementOptions setPreferredAdChoicesPosition: GADAdChoicesPositionTopRightCorner];
}
if ([config objectForKey:@"mediaAspectRatio"]){
[adMediaOptions setMediaAspectRatio:((NSNumber *)[config objectForKey:@"mediaAspectRatio"]).intValue];
diff --git a/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec b/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
index 7b92e8e..5c9e7d4 100755
--- a/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
+++ b/node_modules/react-native-admob-native-ads/react-native-admob-native-ads.podspec
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
# So instead we add the default location of the framework to the framework
# search paths, and we rely on consumers of this library to add
# Google-Mobile-Ads-SDK as a direct dependency.
- s.weak_frameworks = 'GoogleMobileAds', 'FacebookAdapter'
+ s.weak_frameworks = 'GoogleMobileAds', 'MetaAdapter'
s.pod_target_xcconfig = {
'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Google-Mobile-Ads-SDK/Frameworks/**" '\
'"$(PODS_ROOT)/FBAudienceNetwork/**" '\
@@ -27,4 +27,5 @@ Pod::Spec.new do |s|
}
s.dependency 'React-Core'
+ s.dependency 'Google-Mobile-Ads-SDK', '~>9.12.0'
end
@luongminh2410dev Thanks man, I'll update my apps according to your patch