Webview shows error “Didn't find class ”android.webkit.RenderProcessGoneDetail"

后端 未结 4 1551
星月不相逢
星月不相逢 2020-12-03 09:55

My tablet Android version is 7.0 and Chrome version 62.0.3202.84.

When first run my webview app, debug window show

Didn\'t find class \"andro

4条回答
  •  情深已故
    2020-12-03 10:20

    There is a problem with Android after 7.0, but I managed to find a solution. For me it worked to follow this tutorial. In a summary the fragment should look like this:

    public class WebFragment1 extends Fragment{
        public WebFragment1() {
            // Required empty public constructor
        }
    
        WebView wvPage1;
        String url = "http://apptimist.studio";
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
    
            View v = inflater.inflate(R.layout.fragment_web_fragment1, container, false);
            wvPage1 = (WebView)v.findViewById(R.id.wvPage1);
            wvPage1.loadUrl(url);
            WebSettings settings = wvPage1.getSettings();
            settings.setJavaScriptEnabled(true);
            wvPage1.setWebViewClient(new MyWebViewClient());
            return v;
        }
    
        private class MyWebViewClient extends WebViewClient{
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                // TODO Auto-generated method stub
                super.onPageStarted(view, url, favicon);
            }
    
            @SuppressWarnings("deprecation")
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                final Uri uri = Uri.parse(url);
                return true;
            }
    
            @TargetApi(Build.VERSION_CODES.N)
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                view.loadUrl(request.getUrl().toString());
                return true;
            }
        }
    

    I tried without those two lines, but it was not working, so I included them and it worked. Pay attention to add them

    WebSettings settings = wvPage1.getSettings();
    settings.setJavaScriptEnabled(true);
    

    There is the notification that there might be a vulnerability to XSS attacks, you should be opening trusted websites preferably.

    And here is the layout:

    
    
        
    
    
    

    Hope that this will help someone as I spent a lot of time looking for the solution

提交回复
热议问题