blob: 016e23d7c3fd926a0e39c26cb0f39d925055e2ef [file] [log] [blame] [view]
Nate Fischera9029142019-03-01 21:14:361# System WebView Shell
2
Nate Fischer8bd8a112021-04-23 20:45:103[TOC]
4
Nate Fischer599a83b2020-07-30 23:52:395![WebView Shell](images/webview_shell.png)
6
Nate Fischerb84a88e2022-03-10 17:11:007WebView team maintains a "shell"a thin interface over the WebView
8APIsto exercise WebView functionality. The System WebView Shell (AKA
Nate Fischerb9f21ddc2020-07-09 12:15:299"shell browser," "WebView shell") is a standalone app implemented [in
Nate Fischera9029142019-03-01 21:14:3610chromium](/android_webview/tools/system_webview_shell/). While often used for
11manual testing, we also use the shell for automated tests (see our [layout and
12page cycler tests](./test-instructions.md#layout-tests-and-page-cycler-tests)).
13
14*** note
15This relies on the WebView installed on the system. So if you're trying to
16verify local changes to WebView, or run against a specific WebView build, you
17must **install WebView first.**
18***
19
20*** promo
21**Tip:** the shell displays the WebView version (the corresponding [chromium version
22number](https://www.chromium.org/developers/version-numbers)) in the title bar
23at the top. This can be helpful for checking which WebView version is installed
24& selected on the device.
25***
26
Torne (Richard Coles)1eeb5342021-03-29 22:23:5527*** note
28This is *not* a production quality browser and does not implement suitable
29security UI to be used for anything other than testing WebView. This should not
30be shipped anywhere or used as the basis for implementing a browser.
31***
32
Nate Fischere0650422020-03-13 19:02:1233## Setting up the build
34
Nate Fischeraa365932020-04-28 06:35:2935WebView shell only requires `target_os = "android"`. The simplest option is to
36just reuse the same out/ folder and GN args you would normally use for WebView
37or Chrome for Android.
Nate Fischere0650422020-03-13 19:02:1238
Nate Fischeraa365932020-04-28 06:35:2939*** note
40**For the emulator:** the emulator comes with WebView shell preinstalled with a
41different signing key, so installation will fail with
42`INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package ... signatures do not match
43previously installed version`. You can workaround this in your GN args with
44`system_webview_shell_package_name = "org.chromium.my_webview_shell"`.
Nate Fischere0650422020-03-13 19:02:1245
Nate Fischeraa365932020-04-28 06:35:2946Your local build will install alongside the preinstalled WebView shell. You may
47hide the preinstalled shell by running `adb root` followed by `adb shell pm
48disable org.chromium.webview_shell` in your terminal (copy-paste the command
49as-written, **don't** use the package name from the GN arg above).
50***
Nate Fischere0650422020-03-13 19:02:1251
Chris Mumford9d1f8c32019-09-19 23:02:3752## Building the shell
53
54```sh
55$ autoninja -C out/Default system_webview_shell_apk
56```
57
58## Installing the shell
Nate Fischera9029142019-03-01 21:14:3659
60```sh
Nate Fischera9029142019-03-01 21:14:3661$ out/Default/bin/system_webview_shell_apk install
Chris Mumford9d1f8c32019-09-19 23:02:3762```
Nate Fischera9029142019-03-01 21:14:3663
Nate Fischere0650422020-03-13 19:02:1264## Running the shell
Chris Mumford9d1f8c32019-09-19 23:02:3765
Nate Fischere0650422020-03-13 19:02:1266```sh
67# Launch a URL from the commandline, or open the app from the app launcher
68$ out/Default/bin/system_webview_shell_apk launch "https://www.google.com/"
69
70# For more commands:
71$ out/Default/bin/system_webview_shell_apk --help
Chris Mumford9d1f8c32019-09-19 23:02:3772```
73
Nate Fischere0650422020-03-13 19:02:1274*** note
75**Note:** `system_webview_shell_apk` does not support modifying CLI flags. See
76https://crbug.com/959425. Instead, you should modify WebView's flags by
77following [commandline-flags.md](./commandline-flags.md).
78***
79
Nate Fischer8bd8a112021-04-23 20:45:1080## Prebuilt APKs
81
82We maintain a **public** archive of prebuilt WebView shell APKs. This saves you
83the effort of setting up a chromium checkout just for the sake of compiling this
84test app. You can download a prebuilt APK from this cloud storage bucket:
Nate Fischerb5c00c22022-05-21 00:30:4185https://storage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Android/
Nate Fischer8bd8a112021-04-23 20:45:1086
Nate Fischerb5c00c22022-05-21 00:30:41871. Click on the "name" column header **twice**. This will force the page to sort
88 the newest builds toward the top. Click the folder with the largest number,
89 ignoring the `LAST_CHANGE` and `refs_heads_main-*/` folders.
Nate Fischer8bd8a112021-04-23 20:45:1090 * Your WebView shell version **does not** need to match your device's
91 WebView version. We recommend using the latest WebView shell build
92 regardless of your WebView version to make sure you have the latest
93 features and bug fixes of the shell app itself.
941. Click `chrome-android.zip` to download the archived APKs. Unzip this and look
95 for a file named `SystemWebViewShell.apk`.
961. Now you can install this like any other APK:
97
98 ```sh
99 # Install adb if it's not already installed:
100 $ which adb || sudo apt install adb
101
102 # Replace this path with the path to your downloaded APK
103 $ adb install -d -r ~/Downloads/chrome-android/SystemWebViewShell.apk
104 ```
105
Nate Fischerb5c00c22022-05-21 00:30:41106*** note
107**Note:** on the Android emulator, this may fail to install and print the
108`INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package ... signatures do not match
109previously installed version` error message. This may require switching to a
110physical device or compiling the WebView shell from source (see the
111troubleshooting steps below).
112***
113
Nate Fischere0650422020-03-13 19:02:12114## Troubleshooting
115
116### INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE: Package ... signatures do not match previously installed version
117
Nate Fischer3949c892020-09-21 16:40:59118This may be happening because the shell is preinstalled on your device (ex. this
119is the case on all emulators). **The easiest way** to workaround this is to
120[change the shell's package name in a local build](#building-for-the-emulator).
Nate Fischere0650422020-03-13 19:02:12121
Nate Fischer3949c892020-09-21 16:40:59122If you don't want to (or can't) change the package name, then you may be able to
123modify your device's system image. See the [manual steps for removing system
124apps](removing-system-apps.md) and replace **com.google.android.webview** with
125**org.chromium.webview_shell**.