tree: 600555aea5942cbb0e2bebf739b8aae79091d701 [path history] [tgz]
  1. chips-enabled-integration-tests/
  2. integration-tests/
  3. webkit/
  4. .gitignore
  5. OWNERS
  6. README.md
  7. run_instrumentation_tests.sh
webkit/README.md

Jetpack Webkit

See this page rendered in Gitiles markdown.

The Jetpack Webkit library (also known as AndroidX Webkit) 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, as well as access new features available in Android System WebView.

Basic info

Jetpack Webkit and Android System WebView

The Jetpack Webkit library enables developers to access new features that are available in the installed version of Android System WebView, even if those features are not exposed through the android.webkit framework API. It does this by dynamically checking the set of available features through the WebViewFeature class.

You should take care to always check feature availability before calling an API, as you otherwise risk a runtime crash if the WebView provider installed on a users device doesn't support the feature in question. This is most likely to happen if the user in question has not yet updated to a version of Android System WebView that supports the feature, but in rare cases WebView may also stop supporting a previously supported feature as part of an API deprecation.

How to use this library in your app

Add this to your build.gradle file:

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

Important: replace 1.14.0 with the latest version from https://developer.android.com/jetpack/androidx/releases/webkit.

Sample apps

Please check out the WebView samples on GitHub for a showcase of a handful of Jetpack Webkit APIs.

For more APIs, check out the sample app in the AndroidX repo.

Public bug tracker

If you find bugs in the Jetpack Webkit library or want to request new features, please file a ticket.

Experimental APIs

The Jetpack Webkit library contains a number of experimental APIs. These APIs will be marked with annotations that use the @RequiresOptIn annotation. We encourage you to try out these APIs in your application and file feedback if you encounter any issues with the API in the current shape.

When using an experimental API, you should keep the following points in mind:

  • New features or changes may be introduced to experimental APIs. If you are using experimental APIs, we recommend that you always use the latest version of the library in your dependencies, and that you adopt changes in the API as soon as possible. For example, if you are building against the stable version of the library, you should make sure to upgrade to the next stable version as soon as it becomes available.
  • Experimental APIs may be removed from future versions of the library. If this happens, you will not be able to continue using the API by relying on an older version of the library, since the support for the feature will also have been removed from new versions of WebView.
  • The number of WebView versions that support a given experimental API depends on the release status of a given experimental API. For stable library releases, you can expect that WebView versions will continue to offer support until the next stable release of the library. For example, if an experimental API is available in androidx.webkit:webkit:1.14.0, then the stable version of WebView will continue to support the API until androidx.webkit:webkit:1.15.0 has been released, but after the next release the support may then be dropped in WebView versions, depending on the evolution of the API.

Building the library (contributing to the Jetpack library)

If you're trying to modify the Jetpack Webkit library, or apply local changes to the library, you can do so like so:

cd frameworks/support/
# Build the library/compile changes
./gradlew :webkit:webkit:assembleDebug

# Run integration tests with the WebView installed on the device
# using this convenience script:
webkit/run_instrumentation_tests.sh
# or run the tests directly:
./gradlew webkit:integration-tests:instrumentation:connectedAndroidTest \
  -Pandroid.testInstrumentationRunnerArguments.webview-version=factory

# Update API files (only necessary if you changed public APIs)
./gradlew :webkit:webkit:updateApi

For more a detailed developer guide, Googlers should read http://go/wvsl-contribute.

Instrumentation tests

The instrumentation tests for Jetpack Webkit are located in the :webkit:integration-tests:instrumentation project. The tests have been split out into a separate project to facilitate testing against different targetSdk versions.

Any new tests should be added to that project. To run the test, use the command above.