Webkit

Work with modern WebView APIs on Android 5 and above.
Latest Update Stable Release Release Candidate Beta Release Alpha Release
May 24, 2023 1.6.1 - - -

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.6.1"
}

Kotlin

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

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.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.