Skip to content

Installing SystemWebView

Carl edited this page Mar 27, 2022 · 33 revisions

The idea of installing Bromite SystemWebView is to have all apps (and Android itself) use Bromite's features as well.

BEWARE: this is not an officially supported procedure, it may or may not work. Be prepared to restore original SystemWebView if something goes wrong.

Latest version of Bromite SystemWebView can be found here, older versions are available in Releases.

The SystemWebView has had adblocking capabilities from version 72.0.3626.120 up to 76.0.3809.129; current version no more has such capabilities due to upstream changes related to NetworkService (see also https://github.com/bromite/bromite/issues/707).

About the package name

The package name for the Bromite SystemWebView is org.bromite.webview; until v97 the package name was com.android.webview.

For information related to the SystemWebView package name see also:

Basic explanation of how SystemWebView installation works on Android

If org.bromite.webview (or any other, like com.android.webview) is specified in your Android ROM without a signature block then any system package with that name can be used as a SystemWebView provider; packages that are purely user-installed will not be permitted this way, and subsequent package upgrades must have the matching signature of the initial one.

Instead if the package is specified with a signature block then a purely user-installed WebView package can be used as SystemWebView provider; in such case the user-installed SystemWebView package will be usable if it has the right name and right signature (otherwise installation will fail).

Verifying allowed SystemWebView packages

  1. adb pull /system/framework/framework-res.apk
  2. aapt d xmltree framework-res.apk res/xml/config_webview_packages.xml

At this point you will see an output like:

E: webviewproviders (line=20)
  E: webviewprovider (line=21)
    A: availableByDefault=(type 0x12)0xffffffff
    A: description="Chrome Stable" (Raw: "Chrome Stable")
    A: packageName="com.android.chrome" (Raw: "com.android.chrome")
  E: webviewprovider (line=24)
    A: availableByDefault=(type 0x12)0xffffffff
    A: description="Google WebView" (Raw: "Google WebView")
    A: isFallback=(type 0x12)0xffffffff
    A: packageName="com.google.android.webview" (Raw: "com.google.android.webview")
  E: webviewprovider (line=27)
    A: description="Chrome Beta" (Raw: "Chrome Beta")
    A: packageName="com.chrome.beta" (Raw: "com.chrome.beta")
    E: signature (line=28)
      C: "MIIDw...=="
  E: webviewprovider (line=30)
    A: description="Chrome Dev" (Raw: "Chrome Dev")
    A: packageName="com.chrome.dev" (Raw: "com.chrome.dev")
    E: signature (line=31)
      C: "MIIDw...="
  E: webviewprovider (line=33)
    A: description="Chrome Canary" (Raw: "Chrome Canary")
    A: packageName="com.chrome.canary" (Raw: "com.chrome.canary")
    E: signature (line=34)
      C: "MIIDw...="
  E: webviewprovider (line=36)
    A: description="Chrome Debug" (Raw: "Chrome Debug")
    A: packageName="com.google.android.apps.chrome" (Raw: "com.google.android.apps.chrome")

You can install Bromite SystemWebView only if the above output contains a packagename="org.bromite.webview" with the correct signature block or without a corresponding E: signature block (NOTE: without signature it will be UNSECURE as any package with that name can be installed, see previous paragraph explaining how SystemWebView installation works on Android).

NOTE: if you edit res/xml/config_webview_packages.xml and it becomes invalid the system will boot-loop. Care must be taken when editing that file and you will need to have a means to revert the changes in case anything wrong happens.

Bromite SystemWebView signature

The correct signature for Bromite SystemWebView packages is:

MIIDbTCCAlWgAwIBAgIEHcsmjjANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJERTEQMA4GA1UECBMHVW5rbm93bjEPMA0GA1UEBxMGQmVybGluMRAwDgYDVQQKEwdCcm9taXRlMRAwDgYDVQQLEwdCcm9taXRlMRAwDgYDVQQDEwdjc2FnYW41MCAXDTE4MDExOTA3MjE1N1oYDzIwNjgwMTA3MDcyMTU3WjBmMQswCQYDVQQGEwJERTEQMA4GA1UECBMHVW5rbm93bjEPMA0GA1UEBxMGQmVybGluMRAwDgYDVQQKEwdCcm9taXRlMRAwDgYDVQQLEwdCcm9taXRlMRAwDgYDVQQDEwdjc2FnYW41MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtakjGj0eTavbBB2vWXj8KBixWn4zgXAKc+yGFu3SLEGF1VB5aJWwcMHxVI55yH/8M2eNnJP0BkSidfKgPVcm1sk/GrNEs9uk5sWod9byO5M5QWQmGP2REeTd6J0BVVVaMp2MZnqeR3Su3pwFzrSwTqIGyf8dkPSEz7ifj792+EeRNrov4oRQK7lIfqInzwc4d34wU069Lrw6m7J7HM0KbRYISsWMiYj025Qg+dTrtdWt7jbdcj7htW0eYyJoLd90+s43RWnOpENmWpcWv1EVPxUD4mCdV9idYwoHRIESpSu9IWvqDZp1VoRc43nLgsNfNBwmYdTkIaPiz1m7TBcr7QIDAQABoyEwHzAdBgNVHQ4EFgQUuWoGd7W7wMyQ1pOdjiMv10YHTR0wDQYJKoZIhvcNAQELBQADggEBAA7iw6eKz+T8HIpKDoDcX1Ywjn9JUzuCFu20LnsLzreO/Pog1xErYjdLAS7LTZokfbAnitBskO9QhV9BYkDiM0Qr5v2/HsJTtxa1mz9ywCcI36jblMyuXFj8tuwQI9/t9i+Fc3+bOFBV3t7djPo9qX1dIK0lZ6s8HcIhaCNdqm65fH+nWhC/H9djqC6qOtrkTiACKEcHQ4a/5dfROU0q0M4bS4YuiaAQWgjiGbik4LrZ8wZX1aqJCLt0Hs7MzXyyf0cRSO11FIOViHwzh6WTZGufq2J3YBFXPond8kLxkKL3LNezbi5yTcecxsbKQ6OS46CnIKcy/M8asSreLpoCDvw=

You can extract this yourself by using a command like:

unzip -p SystemWebView.apk META-INF/BROMITEK.RSA | openssl pkcs7 -in - -inform DER -print_certs

The signature is the same for all official APKs provided by the Bromite project.

Installed SystemWebView packages

In order to verify which webview packages are installed you can run:

adb shell "pm list packages | grep webview"

Installation options

NOTE: installing the APK in the /system partition will break SafetyNet.

Installation with root and SystemAppMover

You can use /system/app mover to convert the Bromite SystemWebView APK to a system app. After rebooting, the app must be installed again on top of the system app.

Animation of the procedure: Bromite System Webview installation on Android Pie

Installation with root file manager or TWRP

  • go to the webview directory in /system/app/webview (if you do not have such directory, this procedure will not work)
  • cut the webview.apk file and store it on your SD card for backup purposes
  • copy the Bromite SystemWebview apk there and rename it as webview.apk
  • make sure the permissions of webview.apk are 0644 (should be by default)
  • reboot phone
  • install the Bromite SystemWebview apk file as you would for any other app

The apps that need the webview will crash if you do not install the Bromite SystemWebView apk after rebooting. Once the installation is complete it will be possible to update the SystemWebView without root.

Installation without root

Quoting this 25 Jan 2018 post from a Chromium dev:

if you find a way to replace the WebView on a real device without root and without reflashing it with a custom system image, that would be a serious security bug that we would need to fix. There's intentionally no way to do this: on a regular "user" build of android (as opposed to the userdebug/eng variants) all WebView implementation packages must be listed in the system image's configuration and each one must either be preinstalled in the system image, or signed with a specifically designated key, to be permitted.

As per the explanation above, the only options available without root is to flash a custom system image (ROM).

Flashing a custom ROM

You can either modify framework-res.apk or create an overlay so that the changes explained earlier (res/xml/config_webview_packages.xml) allow installation of the Bromite SystemWebView as a system app or an user app.

Verifying installation

After Bromite SystemWebView has been installed you can select it as a WebView provider.

You can also verify that Bromite SystemWebView is being used with an app like WebView Test

Troubleshooting

If you get an error couldn't find "libwebviewchromium.so":

06-21 22:15:19.531 E/WebViewFactory(9456): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/app/webview/webview.apk"],nativeLibraryDirectories=[/system/app/webview/lib/arm64, /system/app/webview/webview.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64, /system/lib64, /system/vendor/lib64]]] couldn't find "libwebviewchromium.so"

Then you can follow these steps to fix it:

  • using apktool open the SystemWebView apk and extract libwebviewchromium.so from /lib/arm64-v8a (for 64-bit devices only)
  • using a file explorer with root access make sure the directory /system/app/webview/lib/arm64/ exists
  • place the copied libwebviewchromium.so inside such directory
  • finally, delete the stock SystemWebView of your ROM (some devices besides having the apk may contain a directory called oat, which also needs to be deleted)
  • paste the new Bromite SystemWebView in place
  • reboot and verify that installation was successful

Chromium related pages