Android WebView 错误未加载 angular Webapp

Android WebView Error Not Loading angular Webapp

提问人:z123 提问时间:9/7/2023 最后编辑:z123 更新时间:9/7/2023 访问量:150

问:

我在android webview中运行一个angular应用程序,但由于某种原因,webview没有加载angular应用程序。我无法测试,因为它在浏览器中完美运行,但失败了。我运行的 android 版本是 4.4.2,但它在运行 android api v29 的模拟器上运行良好。运行应用程序时,我在 android studio 控制台中收到以下错误:

 [INFO:CONSOLE(1)] "Uncaught SyntaxError: Use of const in strict mode.", source: 

    https://app-3f68a52a277a.herokuapp.com/polyfills.ea18fce2c9ce8d9f5540.js (1)
  I/chromium: [INFO:CONSOLE(1)] "Uncaught SyntaxError: Use of future reserved word in strict mode", source: https://app-3f68a52a277a.herokuapp.com/main.3fe416c69fb5797ef75e.js (1)
I/SnapScrollController: setSnapScrollingMode case-default no-op

该应用程序在本地和服务器上完美运行,但 WebView 正在加载一个空页面。当 url 更改为 google 时,它工作得很好。

有谁知道我如何调试确切的问题或解决这个问题?

我的 webview 设置为:

myWebView  = (WebView) findViewById(R.id.webview);
        WebSettings myWebViewSettings = myWebView.getSettings();
        myWebViewSettings.setAllowFileAccess(true);
        myWebViewSettings.setAllowContentAccess(true);
        myWebViewSettings.setAppCacheEnabled(true);
        myWebViewSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
        myWebViewSettings.setJavaScriptEnabled(true);
        myWebViewSettings.setDomStorageEnabled(true);
        myWebViewSettings.setLoadWithOverviewMode(true);
        myWebViewSettings.setUseWideViewPort(true);
        myWebView.setInitialScale(1);
        myWebViewSettings.setUseWideViewPort(true);
        myWebViewSettings.setBuiltInZoomControls(true);


myWebViewSettings.setPluginState(WebSettings.PluginState.ON);
    myWebView.setWebViewClient(new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, final String url) {
        }
        @Override
        public void onPageStarted(WebView view, String url,
                                  Bitmap favicon) {

        }
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            if (handler != null){
                handler.proceed();
            } else {
                super.onReceivedSslError(view, null, error);
            }            }


    });
    myWebViewSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    myWebView.getSettings().setUserAgentString(USER_AGENT);
    myWebView.setWebChromeClient(new WebChromeClient());
    myWebView.setKeepScreenOn(true);
    myWebView.loadUrl("https://app.herokuapp.com");
android 节点 .js 角度 webview 严格模式

评论

0赞 Morrison Chang 9/7/2023
Android 4.4 版(KitKat,API 19)非常旧,并且使用 webview 渲染引擎,该引擎只能在操作系统升级时更新。在 Android 5.0 中,基于 Chromium 的 WebView 变得可更新,developer.chrome.com/docs/multidevice/webview 我会针对较新的设备进行测试,看看是否存在问题。
0赞 z123 9/7/2023
感谢您的帮助,较新的 android 操作系统上不存在问题,但我在较新版本中遇到的另一个问题是 google authentiactes 并卡在加载屏幕上,而不是完成 oauth。
0赞 Morrison Chang 9/7/2023
Oauth 是一个单独的问题。找到:developers.googleblog.com/2021/06/...此外,Android KitKat 失去了 Play 商店服务:arstechnica.com/gadgets/2023/07/...

答: 暂无答案