Приложение попыталось вызвать разрушенный WebView - cordova (Android) - PullRequest
0 голосов
/ 27 апреля 2018

когда я изменяю размер шрифта в настройках мобильного телефона (settings->Display->Font size) Мои приложения Cordova перенаправляют на страницу индекса (Means Root page), и я получаю

Приложение попыталось вызвать уничтоженный WebView

Мой журнал:

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)

Другой журнал:

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)

Может ли кто-нибудь помочь мне через это.

1 Ответ

0 голосов
/ 13 августа 2018

Я получал похожую ошибку, но для adView (который является веб-просмотром). Это помогло мне исправить ошибку с помощью «Приложение попыталось вызвать разрушенный WebView». Замените 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();
}

В других ответах от StackOverflow говорится, что три вышеупомянутых вызова были сделаны для void onDestroy (), но у меня продолжали возникать те же проблемы. Рабочий раствор как показано выше, вы хотите отделить adView.destroy() от removeAllViews() вызовов.

Я также рекомендую вам звонить adView.resume() и adView.pause() в соответствующих местах.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...