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
You can try WebSettings#setSafeBrowsingEnabled(false)
in api level 26. It works for me
Refs: WebSettings#setSafeBrowsingEnabled
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:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.kosalgeek.webviewfragment.WebFragment1">
<WebView
android:id="@+id/wvPage1"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</LinearLayout>
Hope that this will help someone as I spent a lot of time looking for the solution
It appears to be a bug, more details here: https://groups.google.com/a/chromium.org/forum/#!topic/android-webview-dev/m0EtO3IXNn0
On N+ new ART logging appears to have been introduced letting app developers know about certain binary compatibility problems in their code. Unfortunately, this is triggering for some of the API-level guarded code in WebView.
One example is "Failed resolution of: Landroid/webkit/RenderProcessGoneDetail;", which is triggered whenever a recent version of WebView with O features is used on an N device. This is harmless, but confusing and spammy to developers looking at logcat.
I had the same log message but the worst part is that it was opening chrome to load the page. That was a problem since when the back button was pressed, the user was brought back to the activity with a blank page.
So what I did, is I just set the WebViewClient on the webView:
webview.setWebViewClient(new WebViewClient());
Now the error log is gone and the page is loading in the webview.
Hope this helps anyone!