blob: be4cbd74eb541e7959f5b3b754b216cf3eeddbf6 [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
Bruce Dawsonc2661722024-06-12 19:44:2916* An x86-64 machine running Linux with at least 8GB of RAM. More than 16GB is
17 highly recommended.
dpranke0ae7cad2016-11-30 07:47:5818* 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
Alex N. Jose93e74012024-09-23 19:13:2194build/install-build-deps.sh
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
Alex N. Jose93e74012024-09-23 19:13:21101NOTE: For 32-bit builds, the `--lib32` command line switch could be used.
102You may run into issues where `gperf` or `pkgconf` don't get installed,
103without it. To remedy this, and potentially other missing packages, you will
104have to install them manually using:
105
106```shell
107sudo apt-get install {missing_pkg}
108```
109
dpranke0ae7cad2016-11-30 07:47:58110### Run the hooks
tfarinaba2792fa2016-04-07 15:50:42111
dpranke0ae7cad2016-11-30 07:47:58112Once you've run `install-build-deps` at least once, you can now run the
sdy93387fa2016-12-01 01:03:44113Chromium-specific hooks, which will download additional binaries and other
dpranke0ae7cad2016-11-30 07:47:58114things you might need:
tfarinaba2792fa2016-04-07 15:50:42115
sdy93387fa2016-12-01 01:03:44116```shell
Andrew Grievec81af4a2017-07-26 18:02:13117gclient runhooks
sdy93387fa2016-12-01 01:03:44118```
tfarinaba2792fa2016-04-07 15:50:42119
sdy93387fa2016-12-01 01:03:44120*Optional*: You can also [install API
121keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
122build to talk to some Google services, but this is not necessary for most
123development and testing purposes.
tfarinaba2792fa2016-04-07 15:50:42124
dpranke1a70d0c2016-12-01 02:42:29125## Setting up the build
tfarinaba2792fa2016-04-07 15:50:42126
Tom Bridgwatereef401542018-08-17 00:54:43127Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Andrew Williamsbbc1a1e2021-07-21 01:51:22128a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md)
Tom Bridgwatereef401542018-08-17 00:54:43129to generate `.ninja` files. You can create any number of *build directories*
130with different configurations. To create a build directory which builds Chrome
Nate Fischerae5fd3222019-01-11 07:33:18131for Android, run `gn args out/Default` and edit the file to contain the
132following arguments:
tfarinaba2792fa2016-04-07 15:50:42133
Nate Fischerae5fd3222019-01-11 07:33:18134```gn
135target_os = "android"
136target_cpu = "arm64" # See "Figuring out target_cpu" below
Andrew Grieve2f008e22024-05-07 15:21:45137use_remoteexec = true # Enables distributed builds. See "Faster Builds".
Henrique Nakashima5425bb6d2024-12-23 22:09:51138android_static_analysis = "build_server" # Does static checks in background. See "Faster Builds".
sdy93387fa2016-12-01 01:03:44139```
dpranke0ae7cad2016-11-30 07:47:58140
sdy93387fa2016-12-01 01:03:44141* You only have to run this once for each new build directory, Ninja will
142 update the build files as needed.
143* You can replace `Default` with another name, but
144 it should be a subdirectory of `out`.
145* For other build arguments, including release settings, see [GN build
146 configuration](https://www.chromium.org/developers/gn-build-configuration).
Nate Fischerae5fd3222019-01-11 07:33:18147 The default will be a debug component build.
dpranke0ae7cad2016-11-30 07:47:58148* For more info on GN, run `gn help` on the command line or read the
Andrew Williamsbbc1a1e2021-07-21 01:51:22149 [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).
dpranke0ae7cad2016-11-30 07:47:58150
sdy93387fa2016-12-01 01:03:44151Also be aware that some scripts (e.g. `tombstones.py`, `adb_gdb.py`)
dpranke0ae7cad2016-11-30 07:47:58152require you to set `CHROMIUM_OUTPUT_DIR=out/Default`.
153
Nate Fischerae5fd3222019-01-11 07:33:18154### Figuring out target\_cpu
155
156The value of
Andrew Williamsbbc1a1e2021-07-21 01:51:22157[`target_cpu`](https://gn.googlesource.com/gn/+/main/docs/reference.md#var_target_cpu)
Nate Fischerae5fd3222019-01-11 07:33:18158determines what instruction set to use for native code. Given a device (or
159emulator), you can determine the correct instruction set with `adb shell getprop
160ro.product.cpu.abi`:
161
162| `getprop ro.product.cpu.abi` output | `target_cpu` value |
163|-------------------------------------|--------------------|
164| `arm64-v8a` | `arm64` |
165| `armeabi-v7a` | `arm` |
166| `x86` | `x86` |
167| `x86_64` | `x64` |
168
169*** promo
170`arm` and `x86` may optionally be used instead of `arm64` and `x64` for
171non-WebView targets. This is also allowed for Monochrome, but only when not set
Nate Fischer6402abdc2019-07-19 21:50:19172as the WebView provider.
Nate Fischerae5fd3222019-01-11 07:33:18173***
174
dpranke0ae7cad2016-11-30 07:47:58175## Build Chromium
176
177Build Chromium with Ninja using the command:
178
sdy93387fa2016-12-01 01:03:44179```shell
Max Morozf5b31fcd2018-08-10 21:55:48180autoninja -C out/Default chrome_public_apk
sdy93387fa2016-12-01 01:03:44181```
dpranke0ae7cad2016-11-30 07:47:58182
Dirk Pranke8bd55f22018-10-24 21:22:10183(`autoninja` is a wrapper that automatically provides optimal values for the
184arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48185
sdy93387fa2016-12-01 01:03:44186You can get a list of all of the other build targets from GN by running `gn ls
187out/Default` from the command line. To compile one, pass the GN label to Ninja
Dirk Pranke8bd55f22018-10-24 21:22:10188with no preceding "//" (so, for `//chrome/test:unit_tests` use `autoninja -C
sdy93387fa2016-12-01 01:03:44189out/Default chrome/test:unit_tests`).
190
Peter Wenbe712e642019-11-14 21:36:58191### Multiple Chrome Targets
Andrew Grieve052376a2017-09-26 01:54:11192
Andrew Grieve90ba57f2023-05-10 19:07:40193The Google Play Store allows apps to send customized bundles (`.aab` files)
Peter Wenbe712e642019-11-14 21:36:58194depending on the version of Android running on a device. Chrome uses this
Andrew Grievef6069feb2021-04-29 18:29:17195feature to package optimized versions for different OS versions.
Andrew Grieve052376a2017-09-26 01:54:11196
Andrew Grieve90ba57f2023-05-10 19:07:401971. `monochrome_public_bundle` (`MonochromePublic.aab`)
John Rummell987772662024-11-01 20:10:34198 * `minSdkVersion=26` (Oreo).
Andrew Grievef6069feb2021-04-29 18:29:17199 * Contains both Chrome and WebView (to save disk space).
Andrew Grieve90ba57f2023-05-10 19:07:402002. `trichrome_chrome_bundle` (`TrichromeChrome.aab`)
Andrew Grievef6069feb2021-04-29 18:29:17201 * `minSdkVersion=29` (Android 10).
Erik Chend73c50b2024-01-18 02:06:37202 * Native code shared with WebView through a "Static Shared Library APK": `trichrome_library_apk`
Andrew Grievef6069feb2021-04-29 18:29:17203 * Corresponding WebView target: `trichrome_webview_bundle`
Andrew Grieve90ba57f2023-05-10 19:07:402043. `chrome_public_bundle` & `chrome_public_apk` (`ChromePublic.aab`, `ChromePublic.apk`)
John Rummell987772662024-11-01 20:10:34205 * `minSdkVersion=26` (Oreo).
Andrew Grieve90ba57f2023-05-10 19:07:40206 * Used for local development (to avoid building WebView).
207 * WebView packaged independently (`system_webview_bundle` / `system_webview_apk`).
Andrew Grieve052376a2017-09-26 01:54:11208
Andrew Grievef6069feb2021-04-29 18:29:17209*** note
210**Notes:**
211* These instructions use `chrome_public_apk`, but any of the other targets can
212 be substituted.
213* For more about bundles, see [android_dynamic feature modules.md](android_dynamic_feature_modules.md).
214* For more about native library packaging & loading, see [android_native_libraries.md](android_native_libraries.md).
215* There are closed-source equivalents to these targets (for Googlers), which
216 are identical but link in some extra code.
217***
Andrew Grieved2ec82d2018-05-22 14:28:43218
Mark Pearsone9042242018-02-20 23:49:33219## Updating your checkout
220
221To update an existing checkout, you can run
222
223```shell
224$ git rebase-update
225$ gclient sync
226```
227
228The first command updates the primary Chromium source repository and rebases
229any of your local branches on top of tip-of-tree (aka the Git branch
Andrew Williamsbbc1a1e2021-07-21 01:51:22230`origin/main`). If you don't want to use this script, you can also just use
Mark Pearsone9042242018-02-20 23:49:33231`git pull` or other common Git commands to update the repo.
232
233The second command syncs dependencies to the appropriate versions and re-runs
234hooks as needed.
235
dpranke0ae7cad2016-11-30 07:47:58236## Installing and Running Chromium on a device
tfarinaba2792fa2016-04-07 15:50:42237
tfarinaba2792fa2016-04-07 15:50:42238### Plug in your Android device
239
240Make sure your Android device is plugged in via USB, and USB Debugging
241is enabled.
242
243To enable USB Debugging:
244
245* Navigate to Settings \> About Phone \> Build number
246* Click 'Build number' 7 times
247* Now navigate back to Settings \> Developer Options
248* Enable 'USB Debugging' and follow the prompts
249
250You may also be prompted to allow access to your PC once your device is
251plugged in.
252
253You can check if the device is connected by running:
254
255```shell
Yun Liuf57cceaf2019-03-18 21:31:23256third_party/android_sdk/public/platform-tools/adb devices
tfarinaba2792fa2016-04-07 15:50:42257```
258
259Which prints a list of connected devices. If not connected, try
260unplugging and reattaching your device.
tfarinaa68eb902016-04-12 19:43:05261
Thiemo Nagele03fb6c2018-07-31 08:29:31262### Enable apps from unknown sources
263
264Allow Android to run APKs that haven't been signed through the Play Store:
265
266* Enable 'Unknown sources' under Settings \> Security
267
268In case that setting isn't present, it may be possible to configure it via
269`adb shell` instead:
270
271```shell
Yun Liuf57cceaf2019-03-18 21:31:23272third_party/android_sdk/public/platform-tools/adb shell settings put global verifier_verify_adb_installs 0
Thiemo Nagele03fb6c2018-07-31 08:29:31273```
274
tfarinaa68eb902016-04-12 19:43:05275### Build the full browser
276
tfarinaa68eb902016-04-12 19:43:05277```shell
Max Morozf5b31fcd2018-08-10 21:55:48278autoninja -C out/Default chrome_public_apk
tfarinaa68eb902016-04-12 19:43:05279```
280
281And deploy it to your Android device:
282
283```shell
Andrew Grievec81af4a2017-07-26 18:02:13284out/Default/bin/chrome_public_apk install
tfarinaa68eb902016-04-12 19:43:05285```
286
287The app will appear on the device as "Chromium".
288
289### Build Content shell
290
291Wraps the content module (but not the /chrome embedder). See
xiaoyin.l1003c0b2016-12-06 02:51:17292[https://www.chromium.org/developers/content-module](https://www.chromium.org/developers/content-module)
tfarinaa68eb902016-04-12 19:43:05293for details on the content module and content shell.
294
295```shell
Max Morozf5b31fcd2018-08-10 21:55:48296autoninja -C out/Default content_shell_apk
Andrew Grievec81af4a2017-07-26 18:02:13297out/Default/bin/content_shell_apk install
tfarinaa68eb902016-04-12 19:43:05298```
299
300this will build and install an Android apk under
Yipeng Wang613ba692017-04-25 18:24:39301`out/Default/apks/ContentShell.apk`.
tfarinaa68eb902016-04-12 19:43:05302
ntfschr29a7adab2017-03-23 21:17:08303### Build WebView
tfarinaa68eb902016-04-12 19:43:05304
xiaoyin.l1003c0b2016-12-06 02:51:17305[Android WebView](https://developer.android.com/reference/android/webkit/WebView.html)
tfarinaa68eb902016-04-12 19:43:05306is a system framework component. Since Android KitKat, it is implemented using
xiaoyin.l1003c0b2016-12-06 02:51:17307Chromium code (based off the [content module](https://dev.chromium.org/developers/content-module)).
tfarinaa68eb902016-04-12 19:43:05308
ntfschr29a7adab2017-03-23 21:17:08309If you want to build the complete Android WebView framework component and test
310the effect of your chromium changes in Android apps using WebView, you should
311follow the [Android AOSP + chromium WebView
312instructions](https://www.chromium.org/developers/how-tos/build-instructions-android-webview)
tfarinaa68eb902016-04-12 19:43:05313
314### Running
315
tfarinaa68eb902016-04-12 19:43:05316For Content shell:
317
318```shell
Andrew Grievec81af4a2017-07-26 18:02:13319out/Default/bin/content_shell_apk launch [--args='--foo --bar'] http://example.com
tfarinaa68eb902016-04-12 19:43:05320```
321
322For Chrome public:
323
324```shell
Andrew Grievec81af4a2017-07-26 18:02:13325out/Default/bin/chrome_public_apk launch [--args='--foo --bar'] http://example.com
tfarinaa68eb902016-04-12 19:43:05326```
327
tfarinaa68eb902016-04-12 19:43:05328### Logging and debugging
329
330Logging is often the easiest way to understand code flow. In C++ you can print
Andrew Grievec81af4a2017-07-26 18:02:13331log statements using the LOG macro. In Java, refer to
332[android_logging.md](android_logging.md).
tfarinaa68eb902016-04-12 19:43:05333
Andrew Grievec81af4a2017-07-26 18:02:13334You can see these log via `adb logcat`, or:
tfarinaa68eb902016-04-12 19:43:05335
336```shell
Andrew Grievec81af4a2017-07-26 18:02:13337out/Default/bin/chrome_public_apk logcat
tfarinaa68eb902016-04-12 19:43:05338```
339
Tomasz Wiszkowski6467f1c92021-04-08 21:54:42340Logcat supports an additional feature of filtering and highlighting user-defined patterns. To use
341this mechanism, define a shell variable: `CHROMIUM_LOGCAT_HIGHLIGHT` and assign your desired
342pattern. The pattern will be used to search for any substring (ie. no need to prefix or suffix it
343with `.*`), eg:
344
345```shell
346export CHROMIUM_LOGCAT_HIGHLIGHT='(WARNING|cr_Child)'
박중헌e605cf2a2023-08-22 05:17:42347out/Default/bin/chrome_public_apk logcat
Tomasz Wiszkowski6467f1c92021-04-08 21:54:42348# Highlights messages/tags containing WARNING and cr_Child strings.
349```
350
351Note: both _Message_ and _Tag_ portion of logcat are matched against the pattern.
352
Andrew Grievec81af4a2017-07-26 18:02:13353To debug C++ code, use one of the following commands:
tfarinaa68eb902016-04-12 19:43:05354
355```shell
Andrew Grievec81af4a2017-07-26 18:02:13356out/Default/bin/content_shell_apk gdb
357out/Default/bin/chrome_public_apk gdb
tfarinaa68eb902016-04-12 19:43:05358```
359
Philip Jägenstedt17f89962017-05-18 08:25:54360See [Android Debugging Instructions](android_debugging_instructions.md)
tfarinaa68eb902016-04-12 19:43:05361for more on debugging, including how to debug Java code.
362
363### Testing
364
Ken Rockot35028ca2019-05-30 18:50:45365For information on running tests, see
Andrew Grieveb5b3bb32023-10-04 13:55:51366[Android Test Instructions](/docs/testing/android_test_instructions.md)
tfarinaa68eb902016-04-12 19:43:05367
Andrew Grieve2f008e22024-05-07 15:21:45368## Faster Builds
tfarinaa68eb902016-04-12 19:43:05369
Andrew Grieve2f008e22024-05-07 15:21:45370### GN Args
371
agrieveb0861f522018-10-17 19:48:36372Args that affect build speed:
Andrew Grieve2f008e22024-05-07 15:21:45373 * `use_remoteexec = true` *(default=false)*
374 * What it does: Enables distributed builds via Reclient
375 * `symbol_level = 0` *(default=1)*
376 * What it does: Disables debug information in native code.
377 * Use this when doing primarily Java development.
378 * To disable symbols only in Blink / V8: `blink_symbol_level = 0`, `v8_symbol_level = 0`
agrieveb0861f522018-10-17 19:48:36379 * `is_component_build = true` *(default=`is_debug`)*
380 * What it does: Uses multiple `.so` files instead of just one (faster links)
381 * `is_java_debug = true` *(default=`is_debug`)*
Andrew Grieve2f008e22024-05-07 15:21:45382 * What it does: Disables R8 (whole-program Java optimizer)
Andrew Grieve4978e8d2020-07-21 14:29:56383 * `treat_warnings_as_errors = false` *(default=`true`)*
384 * Causes any compiler warnings or lint checks to not fail the build.
385 * Allows you to iterate without needing to satisfy static analysis checks.
Peter Wen9e3ef452022-02-02 16:48:57386 * `android_static_analysis = "build_server"` *(default=`"on"`)*
387 * Offloads static analysis steps to the build server. Explained below.
388 * Set this to `"off"` if you want to turn off static analysis altogether.
389 * `incremental_install = true` *(default=`false`)*
390 * Makes build and install quite a bit faster. Explained in a later section.
Andrew Grieve2f008e22024-05-07 15:21:45391 * `enable_chrome_android_internal = false` *(Googlers only)*
392 * Disables non-public code, which exists even when building public targets.
393 * Use this is you do not need to test internal-only things.
agrieveb0861f522018-10-17 19:48:36394
Andrew Grievef253a882024-12-13 20:02:57395### Asynchronous Static Analysis
Andrew Grieve2f008e22024-05-07 15:21:45396
397Normally analysis build steps like Lint and Error Prone will run as normal build
398steps. The build will then wait for all analysis steps to complete successfully.
399By offloading analysis build steps to a separate build server to be run lazily at
Andrew Grievef253a882024-12-13 20:02:57400a low priority, the actual build can complete much faster.
Peter Wenc4bf57622021-04-12 22:12:36401
Peter Wen38be2fbc2023-02-09 19:04:10402**Note**: Since the build completes before the analysis checks finish, the build
Andrew Grievef253a882024-12-13 20:02:57403will not fail if an analysis check fails.
Peter Wen38be2fbc2023-02-09 19:04:10404
Andrew Grievef253a882024-12-13 20:02:57405To enable this mode, add the gn args:
Peter Wen38be2fbc2023-02-09 19:04:10406
Andrew Grievef253a882024-12-13 20:02:57407```gn
408android_static_analysis = "build_server"
Peter Wen9e3ef452022-02-02 16:48:57409```
410
Andrew Grievef253a882024-12-13 20:02:57411Command output will show up on the terminal that ran the build, as well as in
412`out/Debug/buildserver.log.0`.
413
414See the status of the server at any time via:
415```
416build/android/fast_local_dev_server.py --print-status-all
Victor Hugo Vianna Silva3d39c7f2022-03-21 10:15:27417```
Peter Wen9e3ef452022-02-02 16:48:57418
Jenna Himawan4913cb82025-02-05 15:42:43419### Use Reclient
420
421*** note
422**Warning:** If you are a Google employee, do not follow the Reclient instructions
423in this section. Set up remote execution as described in
424[go/building-android-chrome](https://goto.google.com/building-android-chrome)
425instead.
426***
427
428Chromium's build can be sped up significantly by using a remote execution system
429compatible with [REAPI](https://github.com/bazelbuild/remote-apis). This allows
430you to benefit from remote caching and executing many build actions in parallel
431on a shared cluster of workers.
432
433To use Reclient, follow the corresponding
434[Linux build instructions](linux/build_instructions.md#use-reclient).
435
Andrew Grievef253a882024-12-13 20:02:57436### Incremental Install
Andrew Grievee1dc23f2019-10-22 16:26:36437[Incremental Install](/build/android/incremental_install/README.md) uses
Andrew Grievec45749e52019-10-22 20:59:56438reflection and sideloading to speed up the edit & deploy cycle (normally < 10
Andrew Grievee1dc23f2019-10-22 16:26:36439seconds). The initial launch of the apk will be a lot slower on older Android
440versions (pre-N) where the OS needs to pre-optimize the side-loaded files, but
441then be only marginally slower after the first launch.
tfarinaa68eb902016-04-12 19:43:05442
Andrew Grievee1dc23f2019-10-22 16:26:36443To enable Incremental Install, add the gn args:
tfarinaa68eb902016-04-12 19:43:05444
Andrew Grievee1dc23f2019-10-22 16:26:36445```gn
446incremental_install = true
tfarinaa68eb902016-04-12 19:43:05447```
448
Daniel Cheng243aad32022-02-26 03:33:14449Some APKs (e.g. WebView) do not work with `incremental install = true` and are
450always built as normal APKs. This behavior is controlled via
451`never_incremental = true`.
tfarinaa68eb902016-04-12 19:43:05452
Andrew Grieveae094e392018-06-15 16:10:22453## Installing and Running Chromium on an Emulator
454
455Running on an emulator is the same as on a device. Refer to
Raphael Kubo da Costafe411ff2018-06-20 08:16:50456[android_emulator.md](android_emulator.md) for setting up emulators.
Andrew Grieveae094e392018-06-15 16:10:22457
dpranke0ae7cad2016-11-30 07:47:58458## Tips, tricks, and troubleshooting
tfarinaa68eb902016-04-12 19:43:05459
dpranke0ae7cad2016-11-30 07:47:58460### Rebuilding libchrome.so for a particular release
tfarinaa68eb902016-04-12 19:43:05461
yfriedman9b4327b2016-05-04 16:36:24462These instructions are only necessary for Chrome 51 and earlier.
463
tfarinaa68eb902016-04-12 19:43:05464In the case where you want to modify the native code for an existing
465release of Chrome for Android (v25+) you can do the following steps.
466Note that in order to get your changes into the official release, you'll
467need to send your change for a codereview using the regular process for
468committing code to chromium.
469
4701. Open Chrome on your Android device and visit chrome://version
4712. Copy down the id listed next to "Build ID:"
4723. Go to
473 [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)
4744. Download the listed files and follow the steps in the README.
mohamedhany015ae34802024-10-16 16:34:41475
476### Building with Docker
477
478To build Chromium for Android using Docker, please follow the
479instructions in the [Docker in Linux build instructions](/docs/linux/build_instructions.md#docker).
480
481*** note
482**Note:** You need install the [Android dependencies](#install-additional-build-dependencies) after setting up the [Build dependencies](/docs/linux/build_instructions.md#install-additional-build-dependencies).
483***