To understand webview implementation changes throughout the android versions, we first need to understand what Webview Implementation is : Webview Implementation is functionality that is available in Android OS developer options in the Android 7 and above devices. Using Webview Implementation, users can change which application to be used to provide a WebKit provider to the application which is going to use webviews.
Many Webview Implementation and behavior changes have been made throughout the release of Android versions. Let’s take a look:
Release of Android 5.0(Lollipop) : On the release of Android 5.0 AKA Lollipop, Google has introduced Android System Webview as a separate APK so that WebKit related security issues can be fixed without being bundled to Android System Update. Android System Webview, like any other app can be updated via Google Play store to ensure latest security and other bug fixes are up to date.
Release of Android 7.0(Nougat) : With the release of Android 7.0 AKA Nougat, Google decided to set Google Chrome as default Webkit Provider via Google Webview Implementation. As per Google, This was done because It would be more memory efficient compared to using a separate Android System Webview.
As long as Chrome is enabled in the OS, Android System Webview will not be updated to the latest version via Google Play Store. For the devices which don’t have Chrome enabled, Android OS will automatically use Android System Webview as default webview provider.
With this version, Google Introduced Beta and Dev versions of Google Chrome and Android System Webview which will help developers and users to test cutting edge versions with latest changes, bug fixes and security fixes.
In Android Nougat, Google also introduced an option in Developer Option “Webview Implementation”, Which will allow developers to select what rendering engine/webkit to use to be able to test their websites or browser apps.
Release of Android 10(Q) : With the release of Android 10.0, Google has reinstated Android System Webview as default webview provider replacing Google Chrome as webview provider. In the release of Android 10, Chrome will also use Android System Webview as WebKit provider along with its own internal customization. As per google this will result in more seamless webview integration and reduce download size of Android System Webview.
So now on Android 10+ devices, Android System Webview will be the default provider of WebKit and developers/users can not select Chrome in the WebView Implementation from Developer Options but they can select various versions of Android System Webview like Beta, Dev, Canary and Stable to test latest fixes and implementations.
Below is the table to sum everything up :
Android Version | WebKit Source |
5.0 – 6.0 | Seperated Android System Webview app to manage WebKit updates in Play Store. |
7.0 – 9.0 | Chrome becomes the default provider, If Chrome is disabled/uninstalled then Android System Webview will be used. New Option “Webview Implementation” introduced in Developer Options |
10.0 – Current OS | Android System WebView becomes sole provider. |
How To Detect Current WebKit Provider
To detect Current WebKit provider, you can use the “getCurrentWebViewPackage()” method. However this method is not available for the devices below Android 8.0(Oreo) so developer can use androidx.webkit appcompat library provided by Google.
This method will return PackageInfo object from which you can retrieve the package name and version.
So below is the code for device below and above Android 8.0(Oreo) :
Steps for Android 8.0 and above devices :
- Use below code :
PackageInfo mWebViewInfo = WebView.getCurrentWebViewPackage(context); |
Steps for Android 8.0 below devices :
- Add Dependencies to the project:
dependencies { … implementation ‘androidx.webkit:webkit:1.2.0’ } |
- Use below code :
PackageInfo mWebViewInfo = WebViewCompat.getCurrentWebViewPackage(context); |