App crashes when resuming - java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
See original GitHub issueDescribe the bug Admob shows banner ad without issues. But when app is resumed from background, the app crashes. The following is the error log:
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@acc4c5
I/CordovaLog: Changing log level to DEBUG(3)
I/CordovaActivity: Apache Cordova native platform version 9.0.0 is starting
D/CordovaActivity: CordovaActivity.onCreate()
D/SystemWebViewEngine: CordovaWebView is running on device made by: samsung
D/PluginManager: init()
D/CDVLOGCAT: clearLog
D/Diagnostic: initialize()
D/Diagnostic_Location: initialize()
D/CordovaWebViewImpl: >>> loadUrl(file:///android_asset/www/index.html)
W/IMGSRV: glGetString:4370: Override GL_RENDERER PowerVR SGX Auckland
D/CordovaActivity: Started the activity.
D/CordovaActivity: Resumed the activity.
V/InputMethodManager: Not IME target window, ignoring
D/OpenGLRenderer: eglCreateWindowSurface : 0x8498e160
setSurface succeed. EglSurface(0x8498e160) ANativeSurface(0x849dbc28)
D/CordovaWebViewImpl: onPageDidNavigate(file:///android_asset/www/index.html)
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/JsMessageQueue: Set native->JS mode to EvalBridgeMode
D/CordovaWebViewImpl: onPageFinished(file:///android_asset/www/index.html#/)
I/chromium: [INFO:CONSOLE(1)] "Running cordova-android@9.0.0", source: file:///android_asset/www/js/app.d2c551eb.js (1)
I/AdMobPlus: Initialize plugin
D/AdMobPlus: Execute start
I/chromium: [INFO:CONSOLE(1)] "initialised store", source: file:///android_asset/www/js/app.d2c551eb.js (1)
I/chromium: [INFO:CONSOLE(175)] "OPEN database: lap", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (175)
D/AdMobPlus: Execute ready
V/SQLitePlugin: Android db implementation: built-in android.database.sqlite package
V/info: Open sqlite db: /data/user/0/com.test.New/databases/lap
D/AdMobPlus: Execute bannerLoad
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
W/IMGSRV: glGetString:4370: Override GL_RENDERER PowerVR SGX Auckland
I/Ads: Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("2A148C5533F9CDF0CEFEFEE52905957B")) to get test ads on this device.
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
D/AdMobPlus: Execute bannerShow
I/chromium: [INFO:CONSOLE(179)] "OPEN database: lap - OK", source: file:///android_asset/www/plugins/cordova-sqlite-storage/www/SQLitePlugin.js (179)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
D/InputMethodManager: HSIFW - flag : 0 Pid : 8091
W/com.test.New: Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.New, PID: 8091
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:5109)
at android.view.ViewGroup.addView(ViewGroup.java:4938)
at android.view.ViewGroup.addView(ViewGroup.java:4878)
at android.view.ViewGroup.addView(ViewGroup.java:4851)
at admob.plugin.ads.Banner.addBannerViewWithLinearLayout(Banner.java:242)
at admob.plugin.ads.Banner.addBannerView(Banner.java:216)
at admob.plugin.ads.Banner.show(Banner.java:119)
at admob.plugin.AdMob.lambda$executeBannerShow$2(AdMob.java:132)
at admob.plugin.-$$Lambda$AdMob$wJNZf60vjGVhPuuLD_h6x-vXPpM.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7438)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:989)
I/Process: Sending signal. PID: 8091 SIG: 9
Environment
AdMob Plus Environment Info:
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Memory: 415.91 MB / 7.65 GB
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.16.1 - /usr/bin/node
npm: 6.14.12 - /usr/bin/npm
Languages:
Java: 1.8.0_271 - /usr/bin/javac
npmPackages:
admob-plus-cordova: ^1.5.1 => 1.5.1
cordova-android: ^9.0.0 => 9.0.0
cordova-plugin-androidx-adapter: ^1.1.3 => 1.1.3
cordova-plugin-custom: file:custom_plugins/cordova-plugin-custom => 1.0.0
cordova-plugin-device: ^2.0.3 => 2.0.3
cordova-plugin-dialogs: ^2.0.2 => 2.0.2
cordova-plugin-email-composer: ^0.9.2 => 0.9.2
cordova-plugin-geolocation: ^4.1.0 => 4.1.0
cordova-plugin-native-logs: ^1.0.5 => 1.0.5
cordova-plugin-request-location-accuracy: ^2.3.0 => 2.3.0
cordova-plugin-whitelist: ^1.3.4 => 1.3.4
cordova-sqlite-storage: ^5.1.0 => 5.1.0
cordova.plugins.diagnostic: ^6.0.3 => 6.0.3
npmGlobalPackages:
cordova: 10.0.0
Cordova:
Version: 10.0.0
Plugins:
cordova-plugin-whitelist: ^1.3.4
cordova-plugin-geolocation: ^4.1.0
cordova-plugin-dialogs: ^2.0.2
cordova.plugins.diagnostic: ^6.0.3
cordova-plugin-device: ^2.0.3
cordova-plugin-request-location-accuracy: ^2.3.0
cordova-plugin-native-logs: ^1.0.5
cordova-plugin-email-composer: ^0.9.2
cordova-plugin-androidx-adapter: ^1.1.3
cordova-sqlite-storage: ^5.1.0
admob-plus-cordova: ^1.5.1
cordova-plugin-custom: file:custom_plugins/cordova-plugin-custom
Ionic:
Version: 6.10.1
AndroidManifest.xml:
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" ... />: looks ok
Additional context The following code is run whenever the app resumes from background:
let banner;
document.addEventListener("admob.ready", showBannerAd, false);
async function showBannerAd() {
banner = new admob.BannerAd({
adUnitId: "ca-app-pub-3940256099942544/6300978111",
size: "MEDIUM_RECTANGLE",
});
await banner.show();
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
java - The specified child already has a parent. You must call ...
lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Read more >Bug 761929 - java.lang.IllegalStateException - Bugzilla@Mozilla
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child''s parent first. at android.view.ViewGroup.
Read more >The specified child already has a parent. You must call ...
The inner stack trace for the same is... [0:] ERROR : System.Exception: Register ---> Java.Lang.IllegalStateException: The specified child ...
Read more >The specified child already has a parent. You must call ... - B4X
... 963) java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Read more >[SOLVED] OnResume Crashes but only in signed/aligned version ...
MainActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The latest version resolves this issue.
@1n3JgKl9pQ6cUMrW Thank you very much for your support.
@ratson Thank you for this great plugin, and the amazingly fast fix.
Wishing you both well. 😃
@1n3JgKl9pQ6cUMrW You are the champion, I am able to see the error occasionally with the steps.