web-dev-qa-db-fra.com

L'application a tenté d'appeler une WebView détruite - Cordova (Android)

quand je change la taille de la police dans les paramètres mobiles (settings->Display->Font size)Mes applications Cordova redirigent vers la page d'index (page Racine de Means), et je reçois 

L'application a tenté d'appeler un WebView détruit

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

Un autre journal: 

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)

Quelqu'un peut-il m'aider à traverser ça?.

3
Elangovan E

Je recevais une erreur similaire, mais pour adView (qui est une webview). Cela m'a aidé à corriger mon erreur avec "Application a tenté d'appeler une WebView détruite". Remplacer adView par l'instance d'un WebView devrait fonctionner.

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

D'autres réponses de StackOverflow disent d'effectuer les trois appels ci-dessus sur void onDestroy (), mais j'ai continué à rencontrer les mêmes problèmes. La solution opérationnelle Comme indiqué ci-dessus, vous souhaitez séparer les appels adView.destroy() de removeAllViews().

Je vous recommande également d'appeler adView.resume() et adView.pause() aux endroits appropriés.

1
rated2016