简体   繁体   English

应用程序试图调用已销毁的WebView - cordova(Android)

[英]Application attempted to call on a destroyed WebView - cordova (Android)

when i change the font-size in mobile settings (settings->Display->Font size) My cordova applications redirects to index page(Means Root page), and i am getting 当我在移动设置中更改字体大小时(settings->Display->Font size)我的cordova应用程序重定向到索引页面(手段根页面),我得到了

Application attempted to call on a destroyed WebView 应用程序试图调用已销毁的WebView

My Log: 我的日志:

Application attempted to call on a destroyed WebView java.lang.Throwable at org.chromium.android_webview.AwContents.isDestroyed(AwContents.java:349) at org.chromium.android_webview.AwContents.isDestroyedOrNoOperation(AwContents.jav :321) org.chromium.android_webview.AwContents.getTitle(AwContents.java:576) at org.chromium.android_webview.AwWebContentsDelegateAdapter.loadingStateChanged(AwWebContentsDelegateAdapter.java:132) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:9)at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5451) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Another Log: 另一个日志:

E/ActivityThread: Activity MainActivity has leaked IntentReceiver org.apache.cordova.engine.SystemWebViewEngine$2@5c35c47 that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver org.apache.cordova.engine.SystemWebViewEngine$2@5c35c47 that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:921) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:722) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1193) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1173) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1167) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:561) at org.apache.cordova.engine.SystemWebViewEngine.initWebViewSettings(SystemWebViewEngine.java:242) at org.apache.cordova.engine.SystemWebViewEngine.init(SystemWebViewEngine.java:108) at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:110) at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:149) at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:224) at .MainActivity.adjustFontScale(MainActivity.java:68) at .MainActivity.onCreate(MainActivity.java:47) at android.app.Activity.performCreate(Activity.java:6323) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) at android.app.ActivityThread.access$900(ActivityThread.java:153) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1347) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5451) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 04-27 15:44:30.643 3522-3522/ E/ActivityThread: Activity .MainActivity has leaked IntentReceiver org.apache.cordova.CoreAndroid$5@ea2742b that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver org.apache.cordova.CoreAndroid$5@ea2742b that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:921) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:722) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1193) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1173) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1167) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:561) at org.apache.cordova.CoreAndroid.initTelephonyReceiver(CoreAndroid.java:314) at org.apache.cordova.CoreAndroid.pluginInitialize(CoreAndroid.java:63) at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:58) at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171) at org.apache.cordova.PluginManager.exec(PluginManager.java:122) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57) at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:9) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61) 04-27 15:44:30.644 3522-3522/ E/ActivityThread: Activity .MainActivity has leaked IntentReceiver org.apache.cordova.networkinformation.NetworkManager$1@ee337ef that was originally registered here. Are you missing a call to unregisterReceiver()? android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver org.apache.cordova.networkinformation.NetworkManager$1@ee337ef that was originally registered here. Are you missing a call to unregisterReceiver()? at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:921) at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:722) at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1193) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1173) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1167) at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:561) at org.apache.cordova.networkinformation.NetworkManager.initialize(NetworkManager.java:114) at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:57) at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171) at org.apache.cordova.PluginManager.exec(PluginManager.java:122) at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57) at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:9) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61)

Can anyone help me through this. 谁能帮我解决这个问题。

I was receiving similar error, but for adView (which is a webview). 我收到了类似的错误,但是对于adView(这是一个webview)。 This helped me to fix my error with "Application attempted to call on a destroyed WebView." 这有助于我修复我的错误“应用程序试图调用已销毁的WebView”。 Replace adView with the instance of a WebView, should work. 将adView替换为WebView实例,应该可行。

 @Override
public void onDestroyView() {
    if(adView != null) {
         //rootView is the inflated view of the fragment/activity
        ((ViewGroup) rootView.getParent()).removeAllViews();
        adView.removeAllViews();
        super.onDestroyView();
    }
}

@Override
public void onDestroy() {
    if(adView != null) adView.destroy();
    super.onDestroy();
}

Other answers from StackOverflow say to make the above three calls on void onDestroy() but I continued to experience same problems. StackOverflow的其他答案说要在void onDestroy()上进行上述三次调用,但我仍然遇到同样的问题。 The working solution as seen above, you want to separate the adView.destroy() from removeAllViews() calls. 如上所示的工作解决方案,您想要从removeAllViews()调用中分离adView.destroy()

I also recommend you call adView.resume() and adView.pause() in appropriate places. 我还建议您在适当的位置调用adView.resume()adView.pause()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM