web-dev-qa-db-de.com

Anwendung hat versucht, eine zerstörte WebView aufzurufen - cordova (Android)

wenn ich die Schriftgröße in den mobilen Einstellungen (settings->Display->Font size) ändere, werden meine Cordova-Anwendungen auf die Indexseite (bedeutet Stammseite) umgeleitet.... und ich bekomme 

Anwendung hat versucht, eine zerstörte WebView abzurufen

Mein 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)

Ein anderes Protokoll: 

E/ActivityThread: Activity MainActivity has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? Android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver [email protected] 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 [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? Android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver [email protected] 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 [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()? Android.app.IntentReceiverLeaked: Activity .MainActivity has leaked IntentReceiver [email protected] 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)

Kann mir jemand durch das helfen?.

3
Elangovan E

Ich habe einen ähnlichen Fehler erhalten, aber für AdView (was ein Webview ist). Dies half mir, meinen Fehler mit "Die Anwendung hat versucht, eine zerstörte WebView aufzurufen" zu beheben. AdView durch die Instanz eines WebView ersetzen, sollte funktionieren.

 @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();
}

Andere Antworten von StackOverflow sagen, die drei oben genannten Aufrufe von void onDestroy () zu machen, aber ich hatte weiterhin die gleichen Probleme. Die funktionierende Lösung. Wie Sie oben sehen, möchten Sie die Aufrufe von adView.destroy() von removeAllViews() trennen.

Ich empfehle Ihnen auch, an geeigneten Stellen adView.resume() und adView.pause() anzurufen.

1
rated2016