blob: 6e1976ff31fdd669bf99b709f418efa4030776d4 [file] [log] [blame] [view]
Nate Fischer59c2da762019-03-25 16:46:131# WebView quick start
2
Nate Fischer59c2da762019-03-25 16:46:133*** promo
4Googlers may wish to consult http://go/clank-webview for Google-specific
5developer guides.
6***
7
Nate Fischerfdd8ca152019-06-12 03:24:388[TOC]
9
Nate Fischer59c2da762019-03-25 16:46:1310## Overview
11
12This is not a thorough guide for how to build WebView, but is the **fastest**
13way to get a local build of WebView up and running.
14
15### Building for preview Android releases
16
17Googlers should see internal instructions. External contributors should switch
18to a public (and finalized) Android release (there's no workaround).
19
20## System requirements, tools, etc.
21
22See general Android instructions for:
23
24* [System
25 requirements](/docs/android_build_instructions.md#System-requirements)
Nate Fischer540458a2019-06-12 20:45:3626* [Installing
27 `depot_tools`](/docs/android_build_instructions.md#Install-depot_tools)
Nate Fischerfdd8ca152019-06-12 03:24:3828* [Getting the code](/docs/android_build_instructions.md#Get-the-code) **or**
Nate Fischer59c2da762019-03-25 16:46:1329 [converting a Linux
Nate Fischerfdd8ca152019-06-12 03:24:3830 checkout](/docs/android_build_instructions.md#Converting-an-existing-Linux-checkout)
Nate Fischer59c2da762019-03-25 16:46:1331* [Installing build
Nate Fischerfdd8ca152019-06-12 03:24:3832 dependencies](/docs/android_build_instructions.md#Install-additional-build-dependencies)
33 **and** [running hooks](/docs/android_build_instructions.md#Run-the-hooks)
Nate Fischer59c2da762019-03-25 16:46:1334
35## Device setup
36
37Easiest configuration is to choose a **Google APIs** emulator running **Android
38N or higher**. See [Device Setup](./device-setup.md) for instructions.
39
40*** promo
41**Android O or higher** comes with troubleshooting tools, so that's highly
42recommended.
43***
44
45## Setting up the build
46
Nate Fischerfcb95a92019-05-31 22:58:3847Assuming you took the advice from above, configure GN args (run `gn args
48out/Default`) as follows:
Nate Fischer59c2da762019-03-25 16:46:1349
50```gn
51# Minimal
52target_os = "android"
53target_cpu = "x86" # Assuming you chose an x86 emulator
54
Nate Fischer9df47c72020-07-01 20:57:3355# This package name is allowed for debuggable (userdebug) devices, and lets
Nate Fischer59c2da762019-03-25 16:46:1356# devs install a WebView provider without the usual signature checks. This only
57# works on N+.
58system_webview_package_name = "com.google.android.apps.chrome"
59```
60
61## Build WebView
62
63```shell
64$ autoninja -C out/Default system_webview_apk
65```
66
67## Install WebView and switch provider
68
69```shell
70# Install the APK
71$ out/Default/bin/system_webview_apk install
72
Nate Fischer8810efd2019-04-04 22:04:5473# Tell Android platform to load a WebView implementation from this APK
74$ out/Default/bin/system_webview_apk set-webview-provider
Nate Fischer59c2da762019-03-25 16:46:1375```
76
77## Start running an app
78
79**That it!** Your APK should be installed and should be providing the WebView
80implementation for all apps on the system. If you want to verify this, look at
81the steps for [building the System WebView Shell](./webview-shell.md). The
82version number in the shell's top bar should match the version number in your
83local copy of `//chrome/VERSION`.
84
85## Troubleshooting
86
87If the install command succeeded but something else is wrong, the best way to
88troubleshoot the problem is to query the state of the on-device
89WebViewUpdateService:
90
91```shell
Nate Fischerfa3b0e042019-04-10 00:30:2692# If you don't have `adb` in your path, you can source this file to use
93# the copy from chromium's Android SDK
94$ source build/android/envsetup.sh
95
Nate Fischer59c2da762019-03-25 16:46:1396# Only available on O+
97$ adb shell dumpsys webviewupdate
98
99Current WebView Update Service state
100 Fallback logic enabled: true
101 Current WebView package (name, version): (com.google.android.apps.chrome, 75.0.3741.0)
102 Minimum WebView version code: 303012512
103 Number of relros started: 1
104 Number of relros finished: 1
105 WebView package dirty: false
106 Any WebView package installed: true
107 Preferred WebView package (name, version): (com.google.android.apps.chrome, 75.0.3741.0)
108 WebView packages:
109 Valid package com.android.chrome (versionName: 58.0.3029.125, versionCode: 303012512, targetSdkVersion: 26) is installed/enabled for all users
110 Valid package com.google.android.webview (versionName: 58.0.3029.125, versionCode: 303012500, targetSdkVersion: 26) is NOT installed/enabled for all users
111 Invalid package com.chrome.beta (versionName: 74.0.3729.23, versionCode: 372902311, targetSdkVersion: 28), reason: No WebView-library manifest flag
112 Invalid package com.chrome.dev (versionName: 54.0.2840.98, versionCode: 284009811, targetSdkVersion: 24), reason: SDK version too low
113 Invalid package com.chrome.canary (versionName: 75.0.3741.0, versionCode: 374100010, targetSdkVersion: 25), reason: SDK version too low
114 Valid package com.google.android.apps.chrome (versionName: 75.0.3741.0, versionCode: 2, targetSdkVersion: 28) is installed/enabled for all users
115```
116
117### Invalid package ... No WebView-library manifest flag
118
119This APK does not contain a WebView implementation. Make sure you're building
120`system_webview_apk`.
121
122### Invalid package ... Version code too low
123
124This shouldn't happen for userdebug builds. If it does, add this GN arg:
125
126```gn
127# Any number >= "Minimum WebView version code":
128android_override_version_code = "987654321"
129```
130
131### Invalid package ... SDK version too low
132
133The targetSdkVersion of your APK is too low (it must be >= the platform's API
134level). This shouldn't happen for local builds using tip-of-tree chromium on
135public OS versions (see [note](#Building-for-preview-Android-releases)).
136
137*** note
138**Note:** we only support local development using the latest revision of the
Nate Fischer8924a23f2021-05-04 00:05:25139main branch. Checking out release branches introduces a lot of complexity, and
Nate Fischer59c2da762019-03-25 16:46:13140it might not even be possible to build WebView for your device.
141***
142
Nate Fischer78a27c02019-04-23 19:48:01143### Invalid package ... Incorrect signature
144
145This shouldn't happen for userdebug devices, and there's no workaround for user
146devices. Make sure you have a userdebug device (you can check with `adb shell
147getprop ro.build.type`).
148
149### Valid package ... **is** installed/enabled for all users
Nate Fischer59c2da762019-03-25 16:46:13150
151This is the correct state. If this is not the "preferred WebView package" or the
152"current WebView package", call `set-webview-implementation` again.
153
Nate Fischer78a27c02019-04-23 19:48:01154### Valid package ... **is NOT** installed/enabled for all users
155
156This shouldn't happen for `com.google.android.apps.chrome` (the recommended
157package name). If you need to use a different package name, you may be able to
158workaround this by enabling "redundant packages" (`adb shell cmd webviewupdate
159enable-redundant-packages`), reinstalling, and running `set-webview-provider`
160again.
161
162Otherwise, please [reach out to the team][1].
163
Nate Fischer59c2da762019-03-25 16:46:13164### My package isn't in the list
165
Nate Fischer9df47c72020-07-01 20:57:33166Either your package didn't install (see below) or you chose a package name which
167is [not eligible as a WebView provider](webview-providers.md#Package-name) for
168this device. Double-check the package name in your GN args. If you're on AOSP
169(any OS level), choose `"com.android.webview"`. If you're on L-M, choose
Chris Mumford94fe5edd2019-07-02 19:07:54170`"com.google.android.webview"`. In either case, you'll likely need to [remove
Nate Fischer59c2da762019-03-25 16:46:13171the preinstalled WebView
172APK](/android_webview/tools/remove_preinstalled_webview.py).
173
174### WebView shell doesn't show the correct version
175
176Check the "Current WebView package" in the dumpsys output. You're probably
177hitting one of the cases above.
178
Nate Fischer1dbe66d2019-06-25 20:56:54179### INSTALL\_FAILED\_UPDATE\_INCOMPATIBLE: Package ... signatures do not match previously installed version
180
181This is probably because you've already installed Chrome Debug (ex. with the
182Google-only `monochrome_apk` target, or through a Google-only official build).
183This guide borrows that app's package name, but the locally compiled APK may not
184have the same signing key, causing the `adb install` error. You should remove
185the conflicting package with `out/Default/bin/system_webview_apk uninstall`, and
186then try installing WebView again.
187
Nate Fischer78a27c02019-04-23 19:48:01188### I couldn't install the APK/... is NOT installed.
Nate Fischer59c2da762019-03-25 16:46:13189
190This could fail for an even wider variety of reasons than already listed. Please
Nate Fischer78a27c02019-04-23 19:48:01191[reach out to the team][1].
Nate Fischer59c2da762019-03-25 16:46:13192
193### I couldn't **build** the APK
194
195Try building Chromium. If that doesn't work, please reach out to [the chromium
196team](https://groups.google.com/a/chromium.org/forum/#!forum/chromium-dev) for
197general guidance. If `system_webview_apk` is the only troublesome target, please
198reach out to the WebView team (see previous section).
199
200## What if I didn't follow these instructions exactly?
201
202**Proceed at your own risk.** Building and installing WebView is, for a variety
203of reasons, complex. If you've deviated from **any** of these instructions (and
204don't know what you're doing) there's a good chance of making mistakes (some of
205which don't have any error messages).
206
207If you can't follow the quick start guide for some reason, please consult our
Nate Fischerfdd8ca152019-06-12 03:24:38208[general build instructions](build-instructions.md).
Nate Fischer78a27c02019-04-23 19:48:01209
210[1]: https://groups.google.com/a/chromium.org/forum/#!forum/android-webview-dev