blob: 2e94a05e5fddce398b09b8c1deef76354a9057e8 [file] [log] [blame] [view]
dpranke1a70d0c2016-12-01 02:42:291# Checking out and building Chromium for Android
2
estevenson75e9b862017-01-05 16:49:233There are instructions for other platforms linked from the
dpranke1a70d0c2016-12-01 02:42:294[get the code](get_the_code.md) page.
tfarina2c773222016-04-05 18:43:355
dpranke1a70d0c2016-12-01 02:42:296## Instructions for Google Employees
7
8Are you a Google employee? See
Eric Stevenson36459112018-07-06 20:12:389[go/building-android-chrome](https://goto.google.com/building-android-chrome)
10instead.
dpranke0ae7cad2016-11-30 07:47:5811
tfarina2c773222016-04-05 18:43:3512[TOC]
13
dpranke0ae7cad2016-11-30 07:47:5814## System requirements
tfarina2c773222016-04-05 18:43:3515
dpranke0ae7cad2016-11-30 07:47:5816* A 64-bit Intel machine running Linux with at least 8GB of RAM. More
17 than 16GB is highly recommended.
18* At least 100GB of free disk space.
19* You must have Git and Python installed already.
tfarina2c773222016-04-05 18:43:3520
dpranke0ae7cad2016-11-30 07:47:5821Most development is done on Ubuntu. Other distros may or may not work;
Tom Anderson93e49e492019-12-23 19:55:3722see the [Linux instructions](linux/build_instructions.md) for some suggestions.
tfarina2c773222016-04-05 18:43:3523
dpranke0ae7cad2016-11-30 07:47:5824Building the Android client on Windows or Mac is not supported and doesn't work.
tfarina2c773222016-04-05 18:43:3525
Nate Fischer540458a2019-06-12 20:45:3626## Install depot\_tools
tfarina2c773222016-04-05 18:43:3527
sdy93387fa2016-12-01 01:03:4428Clone the `depot_tools` repository:
dpranke0ae7cad2016-11-30 07:47:5829
sdy93387fa2016-12-01 01:03:4430```shell
Andrew Grievec81af4a2017-07-26 18:02:1331git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
sdy93387fa2016-12-01 01:03:4432```
dpranke0ae7cad2016-11-30 07:47:5833
sdy93387fa2016-12-01 01:03:4434Add `depot_tools` to the end of your PATH (you will probably want to put this
35in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools`
36to `/path/to/depot_tools`:
dpranke0ae7cad2016-11-30 07:47:5837
sdy93387fa2016-12-01 01:03:4438```shell
Andrew Grievec81af4a2017-07-26 18:02:1339export PATH="$PATH:/path/to/depot_tools"
sdy93387fa2016-12-01 01:03:4440```
dpranke0ae7cad2016-11-30 07:47:5841
42## Get the code
43
sdy93387fa2016-12-01 01:03:4444Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5845this whatever you like and put it wherever you like, as
46long as the full path has no spaces):
47
sdy93387fa2016-12-01 01:03:4448```shell
Andrew Grievec81af4a2017-07-26 18:02:1349mkdir ~/chromium && cd ~/chromium
50fetch --nohooks android
sdy93387fa2016-12-01 01:03:4451```
dpranke0ae7cad2016-11-30 07:47:5852
53If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:4454adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:5855
56Expect the command to take 30 minutes on even a fast connection, and many
57hours on slower ones.
58
59If you've already installed the build dependencies on the machine (from another
sdy93387fa2016-12-01 01:03:4460checkout, for example), you can omit the `--nohooks` flag and `fetch`
dpranke0ae7cad2016-11-30 07:47:5861will automatically execute `gclient runhooks` at the end.
62
sdy93387fa2016-12-01 01:03:4463When `fetch` completes, it will have created a hidden `.gclient` file and a
64directory called `src` in the working directory. The remaining instructions
65assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:5866
sdy93387fa2016-12-01 01:03:4467```shell
Andrew Grievec81af4a2017-07-26 18:02:1368cd src
sdy93387fa2016-12-01 01:03:4469```
dpranke0ae7cad2016-11-30 07:47:5870
71### Converting an existing Linux checkout
tfarina2c773222016-04-05 18:43:3572
73If you have an existing Linux checkout, you can add Android support by
Victor Viannae6b228f2022-01-26 14:42:3774appending `target_os = ['linux', 'android']` to your `.gclient` file (in the
sdy93387fa2016-12-01 01:03:4475directory above `src`):
tfarina2c773222016-04-05 18:43:3576
sdy93387fa2016-12-01 01:03:4477```shell
Prakhar5db34ec2024-01-30 19:26:4878echo "target_os = [ 'linux', 'android' ]" >> ../.gclient
sdy93387fa2016-12-01 01:03:4479```
tfarina2c773222016-04-05 18:43:3580
sdy93387fa2016-12-01 01:03:4481Then run `gclient sync` to pull the new Android dependencies:
tfarina2c773222016-04-05 18:43:3582
sdy93387fa2016-12-01 01:03:4483```shell
Andrew Grievec81af4a2017-07-26 18:02:1384gclient sync
sdy93387fa2016-12-01 01:03:4485```
tfarina2c773222016-04-05 18:43:3586
sdy93387fa2016-12-01 01:03:4487(This is the only difference between `fetch android` and `fetch chromium`.)
tfarina2c773222016-04-05 18:43:3588
dpranke0ae7cad2016-11-30 07:47:5889### Install additional build dependencies
tfarina2c773222016-04-05 18:43:3590
dpranke0ae7cad2016-11-30 07:47:5891Once you have checked out the code, run
tfarina2c773222016-04-05 18:43:3592
sdy93387fa2016-12-01 01:03:4493```shell
Ho Cheungfd3ed272023-01-07 02:40:2494build/install-build-deps.sh --android
sdy93387fa2016-12-01 01:03:4495```
tfarina2c773222016-04-05 18:43:3596
sdy93387fa2016-12-01 01:03:4497to get all of the dependencies you need to build on Linux, *plus* all of the
dpranke0ae7cad2016-11-30 07:47:5898Android-specific dependencies (you need some of the regular Linux dependencies
sdy93387fa2016-12-01 01:03:4499because an Android build includes a bunch of the Linux tools and utilities).
tfarina2c773222016-04-05 18:43:35100
dpranke0ae7cad2016-11-30 07:47:58101### Run the hooks
tfarinaba2792fa2016-04-07 15:50:42102
dpranke0ae7cad2016-11-30 07:47:58103Once you've run `install-build-deps` at least once, you can now run the
sdy93387fa2016-12-01 01:03:44104Chromium-specific hooks, which will download additional binaries and other
dpranke0ae7cad2016-11-30 07:47:58105things you might need:
tfarinaba2792fa2016-04-07 15:50:42106
sdy93387fa2016-12-01 01:03:44107```shell
Andrew Grievec81af4a2017-07-26 18:02:13108gclient runhooks
sdy93387fa2016-12-01 01:03:44109```
tfarinaba2792fa2016-04-07 15:50:42110
sdy93387fa2016-12-01 01:03:44111*Optional*: You can also [install API
112keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
113build to talk to some Google services, but this is not necessary for most
114development and testing purposes.
tfarinaba2792fa2016-04-07 15:50:42115
dpranke1a70d0c2016-12-01 02:42:29116## Setting up the build
tfarinaba2792fa2016-04-07 15:50:42117
Tom Bridgwatereef401542018-08-17 00:54:43118Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Andrew Williamsbbc1a1e2021-07-21 01:51:22119a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md)
Tom Bridgwatereef401542018-08-17 00:54:43120to generate `.ninja` files. You can create any number of *build directories*
121with different configurations. To create a build directory which builds Chrome
Nate Fischerae5fd3222019-01-11 07:33:18122for Android, run `gn args out/Default` and edit the file to contain the
123following arguments:
tfarinaba2792fa2016-04-07 15:50:42124
Nate Fischerae5fd3222019-01-11 07:33:18125```gn
126target_os = "android"
127target_cpu = "arm64" # See "Figuring out target_cpu" below
Andrew Grieve2f008e22024-05-07 15:21:45128use_remoteexec = true # Enables distributed builds. See "Faster Builds".
sdy93387fa2016-12-01 01:03:44129```
dpranke0ae7cad2016-11-30 07:47:58130
sdy93387fa2016-12-01 01:03:44131* You only have to run this once for each new build directory, Ninja will
132 update the build files as needed.
133* You can replace `Default` with another name, but
134 it should be a subdirectory of `out`.
135* For other build arguments, including release settings, see [GN build
136 configuration](https://www.chromium.org/developers/gn-build-configuration).
Nate Fischerae5fd3222019-01-11 07:33:18137 The default will be a debug component build.
dpranke0ae7cad2016-11-30 07:47:58138* For more info on GN, run `gn help` on the command line or read the
Andrew Williamsbbc1a1e2021-07-21 01:51:22139 [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).
dpranke0ae7cad2016-11-30 07:47:58140
sdy93387fa2016-12-01 01:03:44141Also be aware that some scripts (e.g. `tombstones.py`, `adb_gdb.py`)
dpranke0ae7cad2016-11-30 07:47:58142require you to set `CHROMIUM_OUTPUT_DIR=out/Default`.
143
Nate Fischerae5fd3222019-01-11 07:33:18144### Figuring out target\_cpu
145
146The value of
Andrew Williamsbbc1a1e2021-07-21 01:51:22147[`target_cpu`](https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu)
Nate Fischerae5fd3222019-01-11 07:33:18148determines what instruction set to use for native code. Given a device (or
149emulator), you can determine the correct instruction set with `adb shell getprop
150ro.product.cpu.abi`:
151
152| `getprop ro.product.cpu.abi` output | `target_cpu` value |
153|-------------------------------------|--------------------|
154| `arm64-v8a` | `arm64` |
155| `armeabi-v7a` | `arm` |
156| `x86` | `x86` |
157| `x86_64` | `x64` |
158
159*** promo
160`arm` and `x86` may optionally be used instead of `arm64` and `x64` for
161non-WebView targets. This is also allowed for Monochrome, but only when not set
Nate Fischer6402abdc2019-07-19 21:50:19162as the WebView provider.
Nate Fischerae5fd3222019-01-11 07:33:18163***
164
dpranke0ae7cad2016-11-30 07:47:58165## Build Chromium
166
167Build Chromium with Ninja using the command:
168
sdy93387fa2016-12-01 01:03:44169```shell
Max Morozf5b31fcd2018-08-10 21:55:48170autoninja -C out/Default chrome_public_apk
sdy93387fa2016-12-01 01:03:44171```
dpranke0ae7cad2016-11-30 07:47:58172
Dirk Pranke8bd55f22018-10-24 21:22:10173(`autoninja` is a wrapper that automatically provides optimal values for the
174arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48175
sdy93387fa2016-12-01 01:03:44176You can get a list of all of the other build targets from GN by running `gn ls
177out/Default` from the command line. To compile one, pass the GN label to Ninja
Dirk Pranke8bd55f22018-10-24 21:22:10178with no preceding "//" (so, for `//chrome/test:unit_tests` use `autoninja -C
sdy93387fa2016-12-01 01:03:44179out/Default chrome/test:unit_tests`).
180
Peter Wenbe712e642019-11-14 21:36:58181### Multiple Chrome Targets
Andrew Grieve052376a2017-09-26 01:54:11182
Andrew Grieve90ba57f2023-05-10 19:07:40183The Google Play Store allows apps to send customized bundles (`.aab` files)
Peter Wenbe712e642019-11-14 21:36:58184depending on the version of Android running on a device. Chrome uses this
Andrew Grievef6069feb2021-04-29 18:29:17185feature to package optimized versions for different OS versions.
Andrew Grieve052376a2017-09-26 01:54:11186
Andrew Grieve90ba57f2023-05-10 19:07:401871. `monochrome_public_bundle` (`MonochromePublic.aab`)
Andrew Grieve4661a66c2022-12-09 14:09:47188 * `minSdkVersion=24` (Nougat).
Andrew Grievef6069feb2021-04-29 18:29:17189 * Contains both Chrome and WebView (to save disk space).
Andrew Grieve90ba57f2023-05-10 19:07:401902. `trichrome_chrome_bundle` (`TrichromeChrome.aab`)
Andrew Grievef6069feb2021-04-29 18:29:17191 * `minSdkVersion=29` (Android 10).
Erik Chend73c50b2024-01-18 02:06:37192 * Native code shared with WebView through a "Static Shared Library APK": `trichrome_library_apk`
Andrew Grievef6069feb2021-04-29 18:29:17193 * Corresponding WebView target: `trichrome_webview_bundle`
Andrew Grieve90ba57f2023-05-10 19:07:401943. `chrome_public_bundle` & `chrome_public_apk` (`ChromePublic.aab`, `ChromePublic.apk`)
Andrew Grieve9f504be2023-02-08 18:08:16195 * `minSdkVersion=24` (Nougat).
Andrew Grieve90ba57f2023-05-10 19:07:40196 * Used for local development (to avoid building WebView).
197 * WebView packaged independently (`system_webview_bundle` / `system_webview_apk`).
Andrew Grieve052376a2017-09-26 01:54:11198
Andrew Grievef6069feb2021-04-29 18:29:17199*** note
200**Notes:**
201* These instructions use `chrome_public_apk`, but any of the other targets can
202 be substituted.
203* For more about bundles, see [android_dynamic feature modules.md](android_dynamic_feature_modules.md).
204* For more about native library packaging & loading, see [android_native_libraries.md](android_native_libraries.md).
205* There are closed-source equivalents to these targets (for Googlers), which
206 are identical but link in some extra code.
207***
Andrew Grieved2ec82d2018-05-22 14:28:43208
Mark Pearsone9042242018-02-20 23:49:33209## Updating your checkout
210
211To update an existing checkout, you can run
212
213```shell
214$ git rebase-update
215$ gclient sync
216```
217
218The first command updates the primary Chromium source repository and rebases
219any of your local branches on top of tip-of-tree (aka the Git branch
Andrew Williamsbbc1a1e2021-07-21 01:51:22220`origin/main`). If you don't want to use this script, you can also just use
Mark Pearsone9042242018-02-20 23:49:33221`git pull` or other common Git commands to update the repo.
222
223The second command syncs dependencies to the appropriate versions and re-runs
224hooks as needed.
225
dpranke0ae7cad2016-11-30 07:47:58226## Installing and Running Chromium on a device
tfarinaba2792fa2016-04-07 15:50:42227
tfarinaba2792fa2016-04-07 15:50:42228### Plug in your Android device
229
230Make sure your Android device is plugged in via USB, and USB Debugging
231is enabled.
232
233To enable USB Debugging:
234
235* Navigate to Settings \> About Phone \> Build number
236* Click 'Build number' 7 times
237* Now navigate back to Settings \> Developer Options
238* Enable 'USB Debugging' and follow the prompts
239
240You may also be prompted to allow access to your PC once your device is
241plugged in.
242
243You can check if the device is connected by running:
244
245```shell
Yun Liuf57cceaf2019-03-18 21:31:23246third_party/android_sdk/public/platform-tools/adb devices
tfarinaba2792fa2016-04-07 15:50:42247```
248
249Which prints a list of connected devices. If not connected, try
250unplugging and reattaching your device.
tfarinaa68eb902016-04-12 19:43:05251
Thiemo Nagele03fb6c2018-07-31 08:29:31252### Enable apps from unknown sources
253
254Allow Android to run APKs that haven't been signed through the Play Store:
255
256* Enable 'Unknown sources' under Settings \> Security
257
258In case that setting isn't present, it may be possible to configure it via
259`adb shell` instead:
260
261```shell
Yun Liuf57cceaf2019-03-18 21:31:23262third_party/android_sdk/public/platform-tools/adb shell settings put global verifier_verify_adb_installs 0
Thiemo Nagele03fb6c2018-07-31 08:29:31263```
264
tfarinaa68eb902016-04-12 19:43:05265### Build the full browser
266
tfarinaa68eb902016-04-12 19:43:05267```shell
Max Morozf5b31fcd2018-08-10 21:55:48268autoninja -C out/Default chrome_public_apk
tfarinaa68eb902016-04-12 19:43:05269```
270
271And deploy it to your Android device:
272
273```shell
Andrew Grievec81af4a2017-07-26 18:02:13274out/Default/bin/chrome_public_apk install
tfarinaa68eb902016-04-12 19:43:05275```
276
277The app will appear on the device as "Chromium".
278
279### Build Content shell
280
281Wraps the content module (but not the /chrome embedder). See
xiaoyin.l1003c0b2016-12-06 02:51:17282[https://www.chromium.org/developers/content-module](https://www.chromium.org/developers/content-module)
tfarinaa68eb902016-04-12 19:43:05283for details on the content module and content shell.
284
285```shell
Max Morozf5b31fcd2018-08-10 21:55:48286autoninja -C out/Default content_shell_apk
Andrew Grievec81af4a2017-07-26 18:02:13287out/Default/bin/content_shell_apk install
tfarinaa68eb902016-04-12 19:43:05288```
289
290this will build and install an Android apk under
Yipeng Wang613ba692017-04-25 18:24:39291`out/Default/apks/ContentShell.apk`.
tfarinaa68eb902016-04-12 19:43:05292
ntfschr29a7adab2017-03-23 21:17:08293### Build WebView
tfarinaa68eb902016-04-12 19:43:05294
xiaoyin.l1003c0b2016-12-06 02:51:17295[Android WebView](https://developer.android.com/reference/android/webkit/WebView.html)
tfarinaa68eb902016-04-12 19:43:05296is a system framework component. Since Android KitKat, it is implemented using
xiaoyin.l1003c0b2016-12-06 02:51:17297Chromium code (based off the [content module](https://dev.chromium.org/developers/content-module)).
tfarinaa68eb902016-04-12 19:43:05298
ntfschr29a7adab2017-03-23 21:17:08299If you want to build the complete Android WebView framework component and test
300the effect of your chromium changes in Android apps using WebView, you should
301follow the [Android AOSP + chromium WebView
302instructions](https://www.chromium.org/developers/how-tos/build-instructions-android-webview)
tfarinaa68eb902016-04-12 19:43:05303
304### Running
305
tfarinaa68eb902016-04-12 19:43:05306For Content shell:
307
308```shell
Andrew Grievec81af4a2017-07-26 18:02:13309out/Default/bin/content_shell_apk launch [--args='--foo --bar'] http://example.com
tfarinaa68eb902016-04-12 19:43:05310```
311
312For Chrome public:
313
314```shell
Andrew Grievec81af4a2017-07-26 18:02:13315out/Default/bin/chrome_public_apk launch [--args='--foo --bar'] http://example.com
tfarinaa68eb902016-04-12 19:43:05316```
317
tfarinaa68eb902016-04-12 19:43:05318### Logging and debugging
319
320Logging is often the easiest way to understand code flow. In C++ you can print
Andrew Grievec81af4a2017-07-26 18:02:13321log statements using the LOG macro. In Java, refer to
322[android_logging.md](android_logging.md).
tfarinaa68eb902016-04-12 19:43:05323
Andrew Grievec81af4a2017-07-26 18:02:13324You can see these log via `adb logcat`, or:
tfarinaa68eb902016-04-12 19:43:05325
326```shell
Andrew Grievec81af4a2017-07-26 18:02:13327out/Default/bin/chrome_public_apk logcat
tfarinaa68eb902016-04-12 19:43:05328```
329
Tomasz Wiszkowski6467f1c92021-04-08 21:54:42330Logcat supports an additional feature of filtering and highlighting user-defined patterns. To use
331this mechanism, define a shell variable: `CHROMIUM_LOGCAT_HIGHLIGHT` and assign your desired
332pattern. The pattern will be used to search for any substring (ie. no need to prefix or suffix it
333with `.*`), eg:
334
335```shell
336export CHROMIUM_LOGCAT_HIGHLIGHT='(WARNING|cr_Child)'
박중헌e605cf2a2023-08-22 05:17:42337out/Default/bin/chrome_public_apk logcat
Tomasz Wiszkowski6467f1c92021-04-08 21:54:42338# Highlights messages/tags containing WARNING and cr_Child strings.
339```
340
341Note: both _Message_ and _Tag_ portion of logcat are matched against the pattern.
342
Andrew Grievec81af4a2017-07-26 18:02:13343To debug C++ code, use one of the following commands:
tfarinaa68eb902016-04-12 19:43:05344
345```shell
Andrew Grievec81af4a2017-07-26 18:02:13346out/Default/bin/content_shell_apk gdb
347out/Default/bin/chrome_public_apk gdb
tfarinaa68eb902016-04-12 19:43:05348```
349
Philip Jägenstedt17f89962017-05-18 08:25:54350See [Android Debugging Instructions](android_debugging_instructions.md)
tfarinaa68eb902016-04-12 19:43:05351for more on debugging, including how to debug Java code.
352
353### Testing
354
Ken Rockot35028ca2019-05-30 18:50:45355For information on running tests, see
Andrew Grieveb5b3bb32023-10-04 13:55:51356[Android Test Instructions](/docs/testing/android_test_instructions.md)
tfarinaa68eb902016-04-12 19:43:05357
Andrew Grieve2f008e22024-05-07 15:21:45358## Faster Builds
tfarinaa68eb902016-04-12 19:43:05359
Andrew Grieve2f008e22024-05-07 15:21:45360### Use Reclient
361
362*** note
363**Warning:** If you are a Google employee, do not follow the instructions below.
364See
365[go/building-android-chrome#initialize-remote-execution-distributed-builds](https://goto.google.com/building-android-chrome#initialize-remote-execution-distributed-builds)
366instead.
367***
368
369Chromium's build can be sped up significantly by using a remote execution system
370compatible with [REAPI](https://github.com/bazelbuild/remote-apis). This allows
371you to benefit from remote caching and executing many build actions in parallel
372on a shared cluster of workers.
373
374To use Reclient, follow the corresponding
375[Linux build instructions](linux/build_instructions.md#use-reclient).
376
377### GN Args
378
agrieveb0861f522018-10-17 19:48:36379Args that affect build speed:
Andrew Grieve2f008e22024-05-07 15:21:45380 * `use_remoteexec = true` *(default=false)*
381 * What it does: Enables distributed builds via Reclient
382 * `symbol_level = 0` *(default=1)*
383 * What it does: Disables debug information in native code.
384 * Use this when doing primarily Java development.
385 * To disable symbols only in Blink / V8: `blink_symbol_level = 0`, `v8_symbol_level = 0`
agrieveb0861f522018-10-17 19:48:36386 * `is_component_build = true` *(default=`is_debug`)*
387 * What it does: Uses multiple `.so` files instead of just one (faster links)
388 * `is_java_debug = true` *(default=`is_debug`)*
Andrew Grieve2f008e22024-05-07 15:21:45389 * What it does: Disables R8 (whole-program Java optimizer)
Andrew Grieve4978e8d2020-07-21 14:29:56390 * `treat_warnings_as_errors = false` *(default=`true`)*
391 * Causes any compiler warnings or lint checks to not fail the build.
392 * Allows you to iterate without needing to satisfy static analysis checks.
Peter Wen9e3ef452022-02-02 16:48:57393 * `android_static_analysis = "build_server"` *(default=`"on"`)*
394 * Offloads static analysis steps to the build server. Explained below.
395 * Set this to `"off"` if you want to turn off static analysis altogether.
396 * `incremental_install = true` *(default=`false`)*
397 * Makes build and install quite a bit faster. Explained in a later section.
Andrew Grieve2f008e22024-05-07 15:21:45398 * `enable_chrome_android_internal = false` *(Googlers only)*
399 * Disables non-public code, which exists even when building public targets.
400 * Use this is you do not need to test internal-only things.
agrieveb0861f522018-10-17 19:48:36401
Andrew Grieve2f008e22024-05-07 15:21:45402### Running Static Analysis Asynchronously
403
404Normally analysis build steps like Lint and Error Prone will run as normal build
405steps. The build will then wait for all analysis steps to complete successfully.
406By offloading analysis build steps to a separate build server to be run lazily at
407a low priority when the machine is idle, the actual build can complete much faster.
Peter Wenc4bf57622021-04-12 22:12:36408
Peter Wen38be2fbc2023-02-09 19:04:10409**Note**: Since the build completes before the analysis checks finish, the build
410will not fail if an analysis check fails. Make sure to check the server's output
411at regular intervals to fix outstanding issues caught by these analysis checks.
412
Andrew Grieve2f008e22024-05-07 15:21:45413#### First way (by running it manually)
Peter Wen38be2fbc2023-02-09 19:04:10414
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27415There are **two** steps to using the build server.
4161. Add the gn arg `android_static_analysis = "build_server"`
4172. Run the script at
418[//build/android/fast_local_dev_server.py][fast_local_dev]
Peter Wen9e3ef452022-02-02 16:48:57419
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27420All your local builds will now forward analysis steps to this server, including
421android lint, errorprone, bytecode processor.
422
423If you run (2) in a terminal, the output of the checks will be displayed there.
Peter Wen38be2fbc2023-02-09 19:04:10424
Andrew Grieve2f008e22024-05-07 15:21:45425#### Second way (using systemd)
Peter Wen38be2fbc2023-02-09 19:04:10426
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27427Alternatively, you can set up the server as a Linux service, so it runs on the
428background and starts on boot. If you're using systemd:
429
Victor Hugo Vianna Silvab137ef4e2022-04-06 17:30:18430Save the following as /etc/systemd/user/fast-local-dev-server.service.
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27431```
432[Unit]
433Description=Chrome server for android build static analysis
434
435[Service]
436Type=simple
437ExecStart=<path to fast_local_dev_server.py>
438Restart=always
439
440[Install]
Victor Hugo Vianna Silvab137ef4e2022-04-06 17:30:18441WantedBy=default.target
Peter Wen9e3ef452022-02-02 16:48:57442```
443
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27444Then
445```bash
Victor Hugo Vianna Silvab137ef4e2022-04-06 17:30:18446systemctl --user daemon-reload
447systemctl --user enable fast-local-dev-server
448systemctl --user start fast-local-dev-server
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27449```
Peter Wen9e3ef452022-02-02 16:48:57450
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27451The output can be inspected with
452```
Victor Hugo Vianna Silvab137ef4e2022-04-06 17:30:18453journalctl --user -e -u fast-local-dev-server
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27454```
Peter Wenc4bf57622021-04-12 22:12:36455
John Palmer046f9872021-05-24 01:24:56456[fast_local_dev]: https://source.chromium.org/chromium/chromium/src/+/main:build/android/fast_local_dev_server.py
Peter Wenc4bf57622021-04-12 22:12:36457
agrieveb0861f522018-10-17 19:48:36458#### Incremental Install
Andrew Grievee1dc23f2019-10-22 16:26:36459[Incremental Install](/build/android/incremental_install/README.md) uses
Andrew Grievec45749e52019-10-22 20:59:56460reflection and sideloading to speed up the edit & deploy cycle (normally < 10
Andrew Grievee1dc23f2019-10-22 16:26:36461seconds). The initial launch of the apk will be a lot slower on older Android
462versions (pre-N) where the OS needs to pre-optimize the side-loaded files, but
463then be only marginally slower after the first launch.
tfarinaa68eb902016-04-12 19:43:05464
Andrew Grievee1dc23f2019-10-22 16:26:36465To enable Incremental Install, add the gn args:
tfarinaa68eb902016-04-12 19:43:05466
Andrew Grievee1dc23f2019-10-22 16:26:36467```gn
468incremental_install = true
tfarinaa68eb902016-04-12 19:43:05469```
470
Daniel Cheng243aad32022-02-26 03:33:14471Some APKs (e.g. WebView) do not work with `incremental install = true` and are
472always built as normal APKs. This behavior is controlled via
473`never_incremental = true`.
tfarinaa68eb902016-04-12 19:43:05474
Andrew Grieveae094e392018-06-15 16:10:22475## Installing and Running Chromium on an Emulator
476
477Running on an emulator is the same as on a device. Refer to
Raphael Kubo da Costafe411ff2018-06-20 08:16:50478[android_emulator.md](android_emulator.md) for setting up emulators.
Andrew Grieveae094e392018-06-15 16:10:22479
dpranke0ae7cad2016-11-30 07:47:58480## Tips, tricks, and troubleshooting
tfarinaa68eb902016-04-12 19:43:05481
dpranke0ae7cad2016-11-30 07:47:58482### Rebuilding libchrome.so for a particular release
tfarinaa68eb902016-04-12 19:43:05483
yfriedman9b4327b2016-05-04 16:36:24484These instructions are only necessary for Chrome 51 and earlier.
485
tfarinaa68eb902016-04-12 19:43:05486In the case where you want to modify the native code for an existing
487release of Chrome for Android (v25+) you can do the following steps.
488Note that in order to get your changes into the official release, you'll
489need to send your change for a codereview using the regular process for
490committing code to chromium.
491
4921. Open Chrome on your Android device and visit chrome://version
4932. Copy down the id listed next to "Build ID:"
4943. Go to
495 [http://storage.googleapis.com/chrome-browser-components/BUILD\_ID\_FROM\_STEP\_2/index.html](http://storage.googleapis.com/chrome-browser-components/BUILD_ID_FROM_STEP_2/index.html)
4964. Download the listed files and follow the steps in the README.
close