Open asad1492 opened 6 years ago
Does this in fact make your application crash? Or is it simply logged as a warning?
If you add the following code during (or right after) initialization of your WebView, does the problem disappear?
if (Build.VERSION.SDK_INT >= 26) {
myWebView.getSettings().setSafeBrowsingEnabled(false);
}
No it's not crashing the application. It's just throwing an exception as warning in the log. And the activity is showing a blank screen. I have changed my code like this but didn't get the success. It's still the same.
mWebView = findViewById(R.id.mWebview); if (Build.VERSION.SDK_INT >= 26) { mWebView.getSettings().setSafeBrowsingEnabled(false); } mWebView.setListener(this, this); mWebView.getSettings().setJavaScriptEnabled(true);
I am having the same issue. Also getting a warning stack trace and a blank webview in stead of my content. Any advice would be greatly appreciated.
I didn't find any solution to this problem. So I have now switched to Chrome Custom Tabs. It's way much better than webview. And it's very easy to implement. Have a look at this https://github.com/codepath/android_guides/wiki/Chrome-Custom-Tabs
This looks interesting but won't help me because I am coding an app that has to work on a custom build of android (AOSP Lollipop) that does not have ANY google content. Chrome cannot be installed. It is quite frustrating.
Oh I see. Best of luck
I think my problem is based on the fact that I have a local webserver serving content to my app. These requests are done with http, not https. And there is now a requirement for safe browsing in the webview component so https requests might do the trick. Looking into making my server secure.
Well, Chrome Custom Tabs are certainly better for some use cases, and worse for several other use cases. WebView and Chrome Custom Tabs serve different needs and use cases. The more important web content is within your application, the more likely you’ll generally be to want WebView.
Regarding this issue here, the android.webkit.SafeBrowsingResponse
is added in Android API level 27, so it’s obvious why it cannot be found on API level 26. The question is why the WebView requests and attempts to find that class.
Disabling “Safe Browsing” programmatically was one idea. Another idea might be disabling it in your manifest:
<manifest>
<application>
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing" android:value="false" />
</application>
</manifest>
If that doesn’t work, the question remains why WebView attempts to do something with “Safe Browsing” although that feature is disabled.
Is this problem solved? I am facing same issue and this one is most similar. I have tried setting safeBrowsing false too , but still my webview sometime loads the local file file:///location/index.html and sometimes goes blank. However, whenever it is blank Failed resolution of: Landroid/webkit/TracingController
appears in logcat.
I am wondering why is this issue still open for last 8 months
As you can see above, two solutions have been suggested but there is not enough feedback to tell whether this issue has been resolved or not.
In general, you’d need to test this on different devices with different Android versions to see where the problem actually occurs.
If the two solutions above don’t work, it’s most likely to be a bug in the built-in WebView implementation of the OS. There may even be some bug report on Android or Chrome’s issue tracker.
the two solutions above don’t work.what else solution can you suggest?
I am facing this exception
"java.lang.NoClassDefFoundError: Failed resolution of: Landroid/webkit/SafeBrowsingResponse" while implementing webview in android.
I have searched for an appropriate solution over the web but didn't find anything useful.]
My XML file is this
` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent">
`
And my java code against this XML is
`public class PaymentActivity extends ParentActivity implements AdvancedWebView.Listener {
// private WebView webView;
private AdvancedWebView mWebView; ProgressDialog dialog; UserModel userModel; SessionManager sessionManager;
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_payment);
}
@Override public void onPageStarted(String url, Bitmap favicon) {
}
@Override public void onPageFinished(String url) { dialog.dismiss(); }
@Override public void onDownloadRequested(String url, String suggestedFilename, String mimeType, long contentLength, String contentDisposition, String userAgent) {
}
@Override public void onExternalPageRequest(String url) {
}
@Override public void onPageError(int errorCode, String description, String failingUrl) {
}`
My compileSdkVersion is 26, minSdkVersion is 17 and targetSdkVersion is 22. I am testing this code on Android 8.0 API 26.
Any help in this regard will be highly appreciated.