The androidx.webkit library is a static library you can add to your Android application in order to use android.webkit APIs that are not available for older platform versions.


The minimum sdk version to use this library is 14.

How to declare the dependencies to use the library

Inside your app's build.gradle file, include this line in dependencies:

dependencies {
    implementation 'androidx.webkit:webkit:1.2.0'

Migrating to androidx.webkit

For static methods:

Old code:

    WebView.startSafeBrowsing(appContext, callback);

New code:

if (WebViewFeature.isFeatureSupported(WebViewFeature.START_SAFE_BROWSING)) {
    WebViewCompat.startSafeBrowsing(appContext, callback);

Or, if you are using a non-static method:

Old code:

    myWebView.postVisualStateCallback(requestId, callback);

New code:

if (WebViewFeature.isFeatureSupported(WebViewFeature.VISUAL_STATE_CALLBACK)) {
    WebViewCompat.postVisualStateCallback(myWebView, requestId, callback);


WebViewAssetLoader.PathHandler A handler that produces responses for a registered path. 
WebViewCompat.VisualStateCallback Callback interface supplied to WebViewCompat.postVisualStateCallback(WebView, long, WebViewCompat.VisualStateCallback) for receiving notifications about the visual state. 
WebViewCompat.WebMessageListener This listener receives messages sent on the JavaScript object which was injected by WebViewCompat.addWebMessageListener(WebView, String, Set, WebViewCompat.WebMessageListener)


JavaScriptReplyProxy This class represents the JavaScript object injected by WebViewCompat#addWebMessageListener
ProxyConfig Config for ProxyController.setProxyOverride(ProxyConfig, Executor, Runnable)
ProxyConfig.Builder ProxyConfig builder. 
ProxyConfig.ProxyRule Class that holds a scheme filter and a proxy URL. 
ProxyController Manages setting and clearing a process-specific override for the Android system-wide proxy settings that govern network requests made by WebView
SafeBrowsingResponseCompat Compatibility version of SafeBrowsingResponse
ServiceWorkerClientCompat Base class for clients to capture Service Worker related callbacks, see ServiceWorkerControllerCompat for usage example. 
ServiceWorkerControllerCompat Manages Service Workers used by WebView. 
ServiceWorkerWebSettingsCompat Manages settings state for all Service Workers. 
TracingConfig Holds tracing configuration information and predefined settings for TracingController
TracingConfig.Builder Builder used to create TracingConfig objects. 
TracingController Manages tracing of WebViews. 
WebMessageCompat The Java representation of the HTML5 PostMessage event. 

The Java representation of the HTML5 message ports. 

WebMessagePortCompat.WebMessageCallbackCompat The listener for handling MessagePort events. 
WebResourceErrorCompat Compatibility version of WebResourceError
WebResourceRequestCompat Compatibility version of WebResourceRequest
WebSettingsCompat Compatibility version of WebSettings  
WebViewAssetLoader Helper class to load local files including application's static assets and resources using http(s):// URLs inside a WebView class. 
WebViewAssetLoader.AssetsPathHandler Handler class to open a file from assets directory in the application APK. 
WebViewAssetLoader.Builder A builder class for constructing WebViewAssetLoader objects. 
WebViewAssetLoader.InternalStoragePathHandler Handler class to open files from application internal storage. 
WebViewAssetLoader.ResourcesPathHandler Handler class to open a file from resources directory in the application APK. 
WebViewClientCompat Compatibility version of WebViewClient
WebViewCompat Compatibility version of WebView  
WebViewFeature Utility class for checking which WebView Support Library features are supported on the device. 
WebViewRenderProcess WebViewRenderProcess provides an opaque handle to a WebView renderer. 
WebViewRenderProcessClient Used to receive callbacks on WebView renderer events.