Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
682 views
in Technique[技术] by (71.8m points)

android - Webview in Oreo not working

I am getting this error while opening a webview in Oreo 8. The device is Google Pixel. Kindly help me with the same. Please let me know if you need any additional information.

Process: com.android.chrome:sandboxed_process0, PID: 16787 android.content.res.Resources$NotFoundException: Array resource ID #0x7f030010 at android.content.res.Resources.obtainTypedArray(Resources.java:617) at android.content.res.Resources.preloadFonts(Resources.java:379) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5815) at android.app.ActivityThread.-wrap1(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.WebViewZygoteInit.main(WebViewZygoteInit.java:121)

    WebSettings settings = binding.landingWb.getSettings();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        settings.setSafeBrowsingEnabled(true);
    }
    //binding.loader.setVisibility(View.GONE);
    settings.setJavaScriptEnabled(true);
    binding.landingWb.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    binding.landingWb.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url != null) {
                if (url.startsWith("whatsapp://")) {
                    view.getContext().startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                    return true;
                } else {
                    view.loadUrl(url);
                    return true;
                }

            } else {
                binding.loader.setVisibility(View.GONE);
                return false;
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            binding.loader.setVisibility(View.GONE);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.d(TAG, "onReceivedError() called with: view = [" + view + "], errorCode = [" + errorCode + "], description = [" + description + "], failingUrl = [" + failingUrl + "]");
            binding.loader.setVisibility(View.GONE);
        }
    });
    binding.landingWb.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            Log.e("CompetitionActivity","Progress:  " + newProgress);
        }
    });
    binding.landingWb.loadUrl(url);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Remove the preloading of fonts by removing

<meta-data 
    android:name="preloaded_fonts" 
    android:resource="@array/preloaded_fonts" />   

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...