Webkit

Work with modern WebView APIs on Android 5 and above.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
March 20, 2024 1.9.0 - 1.11.0-beta01 -

Declaring dependencies

To add a dependency on Webkit, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    implementation "androidx.webkit:webkit:1.9.0"
}

Kotlin

dependencies {
    implementation("androidx.webkit:webkit:1.9.0")
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.11

Version 1.11.0-beta01

March 20, 2024

androidx.webkit:webkit:1.11.0-beta01 is released without any notable changes. Version 1.11.0-beta01 contains these commits.

Version 1.11.0-alpha02

February 21, 2024

androidx.webkit:webkit:1.11.0-alpha02 is released. Version 1.11.0-alpha02 contains these commits.

New Features

  • Add setAudioMuted and isAudioMuted methods for muting (and unmuting) WebViews. This method will allow you to prevent a WebView from playing audio. (Ie7a33)

API Changes

  • URLUtilCompat is made final as it should not be subclassed. (I49ec1)

Version 1.11.0-alpha01

February 7, 2024

androidx.webkit:webkit:1.11.0-alpha01 is released. Version 1.11.0-alpha01 contains these commits.

New Features

  • Add compatibility for URLUtil.guessFileName. The compatibility version in URLUtilCompat supports parsing of Content-Disposition headers that use the filename* encoded value attribute as defined in RFC 6266. The compatibility API also directly exposes a method to parse the Content-Disposition header where a suggested file name based on URL and MIME-type is not desired. (If6ae7, b/309927164)

Version 1.10

Version 1.10.0

January 24, 2024

androidx.webkit:webkit:1.10.0 is released. Version 1.10.0 contains these commits.

Important changes since 1.9.0

Version 1.10.0-rc01

January 10, 2024

androidx.webkit:webkit:1.10.0-rc01 is released. This release contains no changes from the 1.10.0-beta01 release.

Version 1.10.0-beta01

December 13, 2023

androidx.webkit:webkit:1.10.0-beta01 is released. Version 1.10.0-beta01 contains these commits.

  • No functional changes from 1.10.0-alpha01.

Version 1.10.0-alpha01

November 29, 2023

androidx.webkit:webkit:1.10.0-alpha01 is released. Version 1.10.0-alpha01 contains these commits.

New Features

  • Added a new API to WebSettingsCompat to control the experimental Android WebView Media Integrity API behaviour by either disabling the API entirely, or restrict sharing the application identity in the API response. This can be toggled for all origins and on a per origin basis.

Version 1.9

Version 1.9.0

November 29, 2023

androidx.webkit:webkit:1.9.0 is released. Version 1.9.0 contains these commits.

Important changes since 1.8.0

  • Added a new multi-profile API for WebViews.
  • Added an API to inject and run Javascript before page load.
    • The WebViewCompat#addDocumentStartJavascript API allows apps to inject scripts into a WebView which are guaranteed to run before any page scripts are executed. The API allows the app to specify a target list of origins for the script to be enabled on, ensuring that it only runs on intended pages. Unlike WebView#evaluateJavascript, this API will allow execution of scripts in embedded Iframes when they load. Apps can use this new API in combination with WebViewCompat#addWebMessageListener to set up two-way communication with JavaScript in the page in a reliable way.
  • Added APIs to modify how Privacy Sandbox Attribution Reporting events are registered.
    • We introduced a new API WebSettingsCompat#setAttributionRegistrationBehavior which allows developers to configure whether attribution sources and triggers are registered as coming from the app itself or coming from the web content in the WebView. This method can also be used to disable Attribution Reporting in WebView. Additionally we added a new API WebSettingsCompat#getAttributionRegistrationBehavior to get the current behavior.
    • For more information see the Privacy Sandbox documentation.
  • Added APIs to override user-agent metadata for client hints.

Version 1.9.0-rc01

November 15, 2023

androidx.webkit:webkit:1.9.0-rc01 is released. This release contains no changes from the 1.9.0-beta01 release.

Version 1.9.0-beta01

November 1, 2023

androidx.webkit:webkit:1.9.0-beta01 is released. Version 1.9.0-beta01 contains these commits.

API Changes

  • Address user-agent metadata API's nullability issue. We update BrandVersion class to use builder pattern, make the UserAgentMetadata class's getters and setters nullability consistent. (Ibf195)
  • Annotating ProfileStore, WebViewCompat#setProfile and WebViewCompat.getProfile with @UiThread. (I499b2)

Version 1.9.0-alpha01

October 18, 2023

androidx.webkit:webkit:1.9.0-alpha01 is released. Version 1.9.0-alpha01 contains these commits.

New Features

  • We added the multi-profile API which allows you to have separate browsing sessions between WebViews, each profile has its own data (e.g. cookies). You can create profiles, assign them to WebView instances, and retrieve them later for any data access. There is a singleton class ProfileStore to help you manage profiles by creation or deletion with APIs; getOrCreateProfile, getProfile, getAllProfileNames and deleteProfile. The Profile class will have different APIs to use to get associated data with this profile such as its name, GeoLocationPermissions, ServiceWorkerController, CookieManager and WebStorage. Each WebView will run with the default profile by default however, you can change that using WebViewCompat#setProfile Related to that, a WebView’s profile can be retrieved using WebViewCompat#getProfile. (I32d22)
  • Add APIs to modify how Attribution Reporting events are registered. We introduced a new API WebSettingsCompat#setAttributionRegistrationBehavior which allows developers to configure whether sources and triggers are registered as coming from the app itself or coming from the web content in the WebView. This method can also be used to disable Attribution Reporting in WebView. Additionally we added a new API WebSettingsCompat#getAttributionRegistrationBehavior to get the current behavior. For more information see the Privacy Sandbox documentation. (I661f2)
  • Add APIs to override user-agent metadata. We introduced a new API WebSettingsCompat#setUserAgentMetadata to override the user-agent metadata for WebView, which is used to populate the user-agent client hints, and we also added another new API WebSettingsCompat#getUserAgentMetadata to get current user-agent overrides. We encourage apps to use the new API to set the right override values instead of relying on changing user-agent. (I74500)
  • Add an API to inject Javascript to be run during page load. The WebViewCompat.addDocumentStartJavascript API allows apps to inject scripts into a WebView which will be run before any page scripts are executed. The API allows the app to specify a target list of origins for the script to be enabled on, ensuring that it only runs on intended pages. Unlike WebView.evaluateJavascript, this API will allow execution of scripts in embedded Iframes when they load. (Ide063)

Version 1.8

Version 1.8.0

September 6, 2023

androidx.webkit:webkit:1.8.0 is released. Version 1.8.0 contains these commits.

Important changes since 1.7.0

Version 1.8.0-rc01

August 9, 2023

androidx.webkit:webkit:1.8.0-rc01 is released with no changes since 1.8.0-beta01. Version 1.8.0-rc01 contains these commits.

Version 1.8.0-beta01

July 26, 2023

androidx.webkit:webkit:1.8.0-beta01 is released with no changes since 1.8.0-alpha01. Version 1.8.0-beta01 contains these commits.

Version 1.8.0-alpha01

June 7, 2023

androidx.webkit:webkit:1.8.0-alpha01 is released. Version 1.8.0-alpha01 contains these commits.

API Changes

  • See the External Contribution section.

External Contribution

  • Add support for passing ArrayBuffer over WebMessagePortCompat#postMessage, JsReplyProxy#postMessage and WebViewCompat#postWebMessage, receiving ArrayBuffer from JavaScript over WebMessagePortCompat and WebMessageListener, and receiving transferable ArrayBuffer from JavaScript over WebMessagePortCompat. Please note that this API will only be available from WebView version 116. (Ie7567, b/251152171)

Version 1.7

Version 1.7.0

May 24, 2023

androidx.webkit:webkit:1.7.0 is released. Version 1.7.0 contains these commits.

Important changes since 1.6.0

  • We added support for Image drag in WebView. You can enable your users to drag images out of the WebView by adding the new DropDataContentProvider to your app's manifest as described in the class documentation.
  • We added the ProcessGlobalConfig#setDirectoryBasePaths(Context,File,File) API which can be used to set the base directories that WebView will use for the current process. As with all methods on ProcessGlobalConfig, this method must be called before the first instance of WebView is instantiated. This method is added to provide Android framework the capability to tweak WebView settings. For general purpose applications, using this method is not recommended.

Version 1.7.0-rc01

May 10, 2023

androidx.webkit:webkit:1.7.0-rc01 is released with no changes since 1.7.0-beta01. Version 1.7.0-rc01 contains these commits.

Version 1.7.0-beta01

April 5, 2023

androidx.webkit:webkit:1.7.0-beta01 is released. Version 1.7.0-beta01 contains these commits.

API Changes

  • Minor change to feature flag and method name and make setDirectoryBasePaths() accept File instead of String (Ib0d0a)

Version 1.7.0-alpha03

March 8, 2023

androidx.webkit:webkit:1.7.0-alpha03 is released. Version 1.7.0-alpha03 contains these commits.

API Changes

  • Add ProcessGlobalConfig#setDirectoryBasePath(String, String) API which can be used to set the base directories that WebView will use for the current process. (Ibd1a1, b/250553687)

Bug Fixes

  • Fix invalid ProGuard rule causing build errors when using DexGuard (Ia65c2, b/270034835)

Version 1.7.0-alpha02

February 8, 2023

androidx.webkit:webkit:1.7.0-alpha02 is released. Version 1.7.0-alpha02 contains these commits.

Bug Fixes

  • Documentation bugs for DropDataContentProvider.

Version 1.7.0-alpha01

January 25, 2023

androidx.webkit:webkit:1.7.0-alpha01 is released. Version 1.7.0-alpha01 contains these commits.

New Features

  • We are adding support for Image drag in WebView. You can enable your users to drag images out of the WebView by adding the new DropDataContentProvider to your app's manifest. (05a1a6)

Version 1.6

Version 1.6.1

March 22, 2023

androidx.webkit:webkit:1.6.1 is released. Version 1.6.1 contains these commits.

Bug Fixes

  • Fix proguard parse error (Ia65c2)

Version 1.6.0

January 25, 2023

androidx.webkit:webkit:1.6.0 is released. Version 1.6.0 contains these commits.

Important changes since 1.5.0

  • A new ProcessGlobalConfig API has been added to allow apps to provide configuration settings that need to be set before loading WebView, such as the WebView data directory suffix. The configuration should be set up and applied as early as possible during application startup, to ensure that it happens before any other thread can call a method that loads WebView into the process.
  • A new CookieManagerCompat API has been added to expand android.webkit.CookieManager with a new getCookieInfo method, which retrieves all attributes for all cookies set on a specific URL. This differs from the existing getCookie API in CookieManager which returns only the name and value attributes of the cookies.
  • WebSettingsCompat has new methods to enable/disable the effect of EnterpriseAuthenticationAppLinkPolicy if set by admin in WebView, and to get the current setting. This feature lets WebView open an Authentication app instead of opening the authentication URL. This feature has no effect on devices that are not managed by an enterprise policy.
  • Adding a new API to WebSettingsCompat to let applications explicitly send the app package name in the X-Requested-With header to allowlisted origins. The header has traditionally been sent on every request from WebView.

Version 1.6.0-rc01

January 11, 2023

androidx.webkit:webkit:1.6.0-rc01 is released. Version 1.6.0-rc01 contains these commits.

Bug Fixes

  • Fixed NullPointerException in WebViewFeature.isStartupFeatureSupported(Context, String) when running on SDK < L. (Ic7292)

Version 1.6.0-beta01

December 7, 2022

androidx.webkit:webkit:1.6.0-beta01 is released. Version 1.6.0-beta01 contains these commits.

API Changes

  • ProcessGlobalConfig has been changed to use a normal constructor and a static apply method. The apply method should only be called once per process, as early as possible, and will throw IllegalStateException if called more than once. ProcessGlobalConfig objects no longer have any restrictions on how many times setters can be called. (I456c3)

Version 1.6.0-alpha03

November 9, 2022

androidx.webkit:webkit:1.6.0-alpha03 is released. Version 1.6.0-alpha03 contains these commits.

New Features

  • Add ProcessGlobalConfig class enabling users to set process global config before loading WebView. WebView has some process-global configuration parameters that cannot be changed once WebView has been loaded (e.g. the WebView data directory). This class allows apps to set these parameters. The configuration should be set up and applied as early as possible during application startup, to ensure that it happens before any other thread can call a method that loads WebView into the process. (I7c0e0, b/250553687)
  • Adding new API to let applications explicitly send the app package name in the X-Requested-With header to allowlisted origins. The header has traditionally been sent on every request from WebView. (I0adfe, b/226552535)

API Changes

  • The WebSettingsCompat#setAlgorithmicDarkeningAllowed API is supported on all Android versions in WebView version 105 and later. Previous versions of WebView only supported the API on Android Q and later. As a result, this api is no longer marked @RequiresApi(Build.VERSION_CODES.Q). (I3ac1d)

Version 1.6.0-alpha02

October 24, 2022

androidx.webkit:webkit:1.6.0-alpha02 is released. Version 1.6.0-alpha02 contains these commits.

New Features

  • Adds a new CookieManagerCompat class along with a getCookieInfo API which retrieves all attributes for all cookies set on a specific URL. This differs from the existing getCookie API in CookieManager which returns only the name and value attributes of the cookies. (I07365, b/242161756)

Version 1.6.0-alpha01

August 24, 2022

androidx.webkit:webkit:1.6.0-alpha01 is released. Version 1.6.0-alpha01 contains these commits.

New Features

  • Added APIs in WebSettingsCompat to enable/disable the effect of EnterpriseAuthenticationAppLinkPolicy if set by admin in WebView. This feature lets WebView open an Authentication app instead of opening the authentication URL. This feature has no effect on devices that are not managed by an enterprise policy.

Version 1.5.0

Version 1.5.0

August 24, 2022

androidx.webkit:webkit:1.5.0 is released. Version 1.5.0 contains these commits.

Important changes since 1.4.0

  • A new setAlgorithmicDarkeningAllowed API on WebSettingsCompat replaces the old setForceDark and setForceDarkStrategy APIs. Apps targeting SDK 33 and higher (T) should use the new API, as the old API will no longer have any effect for those apps.
  • An allow-list of URLs to use the configured proxy can now be set through ProxyCofig.Builder by setting setReverseBypassEnabled to true. When this is in effect, all other URLs will bypass the configured proxy.

Version 1.5.0-rc01

August 10, 2022

androidx.webkit:webkit:1.5.0-rc01 is released with no changes since 1.5.0-beta01. Version 1.5.0-rc01 contains these commits.

Version 1.5.0-beta01

June 29, 2022

androidx.webkit:webkit:1.5.0-beta01 is released. Version 1.5.0-beta01 contains these commits.

API Changes

  • Alogrithimic Darkening related APIs are now annotated to require API level Q. The API will not have any effect on API levels < Q, since dark theme is not an option on these devices. (I0905e)

Version 1.5.0-alpha01

May 18, 2022

androidx.webkit:webkit:1.5.0-alpha01 is released. Version 1.5.0-alpha01 contains these commits.

New Features

  • Add a new getVariationsHeader() method on WebViewCompat to get the X-Client-Data header value sent by the WebView. The returned value will be a base64 encoded ClientVariations protobuf.
  • Add APIs on WebSettingsCompat to allow/disallow algorithmic darkening for app with targetSdk >= 33. (I29597)

API Changes

  • Add a new method in ProxyCofig.Builder to set reverse bypass. Setting reverse bypass to true means only URLs in the bypass list will use the proxy settings. (I9eaa2, b/168728599)

Bug Fixes

  • Fixed a typo in dark theme documentation. (I36ebf, b/194343633)
  • Fixed a bug where WebViewAssetLoader.Builder methods were unintentionally order-dependent. (If420d, b/182196765)

Version 1.4.0

Version 1.4.0

December 16, 2020

androidx.webkit:webkit:1.4.0 is released. Version 1.4.0 contains these commits.

Major changes since 1.3.0

  • Added a new setSafeBrowsingAllowlist() API to replace setSafeBrowsingWhitelist(). This helps apps update their code to avoid non-inclusive terminology, while still supporting the same range of Android SDKs and WebView versions as the deprecated API.
  • Fixed a bug in setProxyOverride that caused fallback rules not being correctly applied.

Version 1.4.0-rc02

December 2, 2020

androidx.webkit:webkit:1.4.0-rc02 is released. Version 1.4.0-rc02 contains these commits.

Bug Fixes

  • Fixes fallback rules not being correctly applied when using setProxyOverride.

Version 1.4.0-rc01

November 11, 2020

androidx.webkit:webkit:1.4.0-rc01 is released with no changes since 1.4.0-beta01. Version 1.4.0-rc01 contains these commits.

Version 1.4.0-beta01

October 14, 2020

androidx.webkit:webkit:1.4.0-beta01 is released with no changes since 1.4.0-alpha01. Version 1.4.0-beta01 contains these commits.

Version 1.4.0-alpha01

September 16, 2020

androidx.webkit:webkit:1.4.0-alpha01 is released. Version 1.4.0-alpha01 contains these commits.

API Changes

  • Added a new WebViewCompat#setSafeBrowsingAllowlist() API to replace setSafeBrowsingWhitelist(). This helps apps update their code to avoid non-inclusive terminology, while still supporting the same range of Android SDKs and WebView versions as the deprecated API. (I8d65d)

Version 1.3.0

Version 1.3.0

August 19, 2020

androidx.webkit:webkit:1.3.0 is released. Version 1.3.0 contains these commits.

Major changes since 1.2.0

  • ForceDarkStrategy API provides more control to WebView darkening (CSS/web content darkening versus auto darkening).
  • WebMessageListener and its related APIs provide a simple and secure mechanism to establish communication between web contents and the WebView embedder app.
  • isMultiProcessEnabled API to check whether WebView is running in multi process. This is possible starting in Android O and it means web content is rendered in a sandboxed renderer process separate to the application process. This sandboxed renderer may be shared with other WebViews in the same application but it's not shared with other application processes.

Version 1.3.0-rc02

August 5, 2020

androidx.webkit:webkit:1.3.0-rc02 is released. Version 1.3.0-rc02 contains these commits.

Bug Fixes

  • This fixes a compatibility issue where WebMessageListener would sometimes crash during local development if your app was started with Android Studio instant run.

Version 1.3.0-rc01

June 24, 2020

androidx.webkit:webkit:1.3.0-rc01 is released with no changes since 1.3.0-beta01. Version 1.3.0-rc01 contains these commits.

Version 1.3.0-beta01

June 10, 2020

androidx.webkit:webkit:1.3.0-beta01 is released. Version 1.3.0-beta01 contains these commits.

New Features

  • ForceDarkStrategy API to control WebView darkening (CSS/web content darkening versus auto darkening).
  • WebMessageListener APIs provide a simple and secure mechanism to establish communication between web contents and the WebView embedder app.
  • MultiProcessEnabled API to check if WebView is running in multi process mode.

Version 1.3.0-alpha03

May 27, 2020

androidx.webkit:webkit:1.3.0-alpha03 is released. Version 1.3.0-alpha03 contains these commits.

API Changes

  • addWebMessageListener method now receives a Set<String> of allowed origin rules (previously a List<String>).

Version 1.3.0-alpha02

April 29, 2020

androidx.webkit:webkit:1.3.0-alpha02 is released. Version 1.3.0-alpha02 contains these commits.

New Features

  • MultiProcessEnabled API to check if WebView is running in multi process mode.

API Changes

  • All dark strategy constants are now prefixed with DARK_STRATEGY.

Version 1.3.0-alpha01

April 15, 2020

androidx.webkit:webkit:1.3.0-alpha01 is released. Version 1.3.0-alpha01 contains these commits.

New Features

  • ForceDarkStrategy API to control WebView darkening (CSS/web content darkening versus auto darkening).
  • WebMessageListener APIs provide a simple and secure mechanism to establish communication between web contents and the WebView embedder app.

Version 1.2.0

Version 1.2.0

March 4, 2020

androidx.webkit:webkit:1.2.0 is released. Version 1.2.0 contains these commits.

Major changes since 1.1.0

  • Added the ForceDark API to control if WebViews should be rendered in dark mode.

Version 1.2.0-rc01

February 19, 2020

androidx.webkit:webkit:1.2.0-rc01 is released with no changes since 1.2.0-beta01. Version 1.2.0-rc01 contains these commits.

Version 1.2.0-beta01

February 5, 2020

androidx.webkit:webkit:1.2.0-beta01 is released with no changes since 1.2.0-alpha01. Version 1.2.0-beta01 contains these commits.

Version 1.2.0-alpha01

December 18, 2019

androidx.webkit:webkit:1.2.0-alpha01 is released. Version 1.2.0-alpha01 contains these commits.

New features

  • ForceDark API to control if WebViews should be rendered in dark mode.

Version 1.1.0

Version 1.1.0

November 7, 2019

androidx.webkit:webkit:1.1.0 is released. Version 1.1.0 contains these commits.

Important changes since 1.0.0

  • Getter APIs to complement setWebViewClient() and setWebChromeClient().
  • ProxyController API to set a network request proxy for an app's WebViews.
  • WebViewAssetLoader API to simplify loading APK assets, resources, and files from the app data directory via request interception. This allows access to web and local resources without disabling CORS.
  • TracingController API to collect WebView tracing information for debugging purposes.
  • RenderProcess APIs to manage WebView renderer services, and to detect when poorly behaved content causes WebView renderers to become unresponsive.
  • Updated existing APIs to include nullability (@NonNull, @Nullable) and thread (@UiThread, @WorkerThread) annotations.

Version 1.1.0-rc01

October 9, 2019

androidx.webkit:webkit:1.1.0-rc01 is released. Version 1.1.0-rc01 contains these commits.

Bug fixes

  • Fixed an issue where setWebViewRenderProcessClient() could crash if passed a null client.

Version 1.1.0-beta01

September 5, 2019

androidx.webkit:webkit:1.1.0-beta01 is released. The commits included in this version can be found here.

New features

  • New InternalStoragePathHandler in WebViewAssetLoader to load files from the app's data directory.

API changes

  • ProxyConfig#getProxyRules() now returns an unmodifiable list of ProxyRule instances, which is a new class to hold a scheme filter and its corresponding proxy URL.

Bug fixes

  • WebViewAssetLoader defaults to a "text/plain" MIME type (rather than null) when it can't guess the MIME type from the file path.
  • WebViewAssetLoader no longer throws a NullPointerException when loading files with special characters in their path names.

Version 1.1.0-alpha02

August 7, 2019

androidx.webkit:webkit:1.1.0-alpha02 is released. The commits included in this version can be found here.

New features

  • WebViewAssetLoader exposes the PathHandler interface to allow apps to create custom path-handling functionality.

API changes

  • WebViewAssetLoader is now a final class, since it's not meant to be subclassed.
  • WebViewAssetLoader#PathHandler implementations are now public and final.
  • Minor changes to ProxyConfig method names.
  • ProxyController: added new methods addDirect() and addDirect(String) to connect directly to servers; removed DIRECT String.
  • Updated existing APIs to include nullability (@NonNull, @Nullable) and thread (@UiThread, @WorkerThread) annotations.

Version 1.1.0-alpha01

May 7, 2019

androidx.webkit:webkit:1.1.0-alpha01 is released. The commits included in this version can be found here.

New features

  • Getter APIs to complement setWebViewClient() and setWebChromeClient()
  • ProxyController API to set a network request proxy for an app's WebViews.
  • AssetLoader API to simplify loading APK assets and resources via request interception, allowing access to web resources without disabling CORS.
  • TracingController API to collect WebView tracing information for debugging purposes.
  • RenderProcess APIs to manage WebView renderer services, and to detect when poorly behaved content causes WebView renderers to become unresponsive.

Bug fixes

  • Minor fixes to documentation formatting for existing APIs.