blob: 4e4b693e511c5d2afadedcf4744d6325056c6c3d [file] [log] [blame] [view]
dprankec641a5342017-04-04 02:35:011# Checking out and building Cast for Android
2
3**Note**: it is **not possible** to build a binary functionally
4equivalent to a Chromecast. This is to build a single-page content
5embedder with similar functionality to Cast products.
6
7## Instructions for Google Employees
8
9Are you a Google employee? See
10[go/building-android-cast](https://goto.google.com/building-android-cast) instead.
11
12[TOC]
13
14## System requirements
15
16* 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.
20
21Most development is done on Ubuntu. Other distros may or may not work;
22see the [Linux instructions](linux_build_instructions.md) for some suggestions.
23
24Building the Android client on Windows or Mac is not supported and doesn't work.
25
26## Install `depot_tools`
27
28Clone the `depot_tools` repository:
29
30```shell
31$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
32```
33
34Add `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`:
37
38```shell
39$ export PATH="$PATH:/path/to/depot_tools"
40```
41
42## Get the code
43
44Create a `chromium` directory for the checkout and change to it (you can call
45this whatever you like and put it wherever you like, as
46long as the full path has no spaces):
47
48```shell
49$ mkdir ~/chromium && cd ~/chromium
50$ fetch --nohooks android
51```
52
53If you don't want the full repo history, you can save a lot of time by
54adding the `--no-history` flag to `fetch`.
55
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
60checkout, for example), you can omit the `--nohooks` flag and `fetch`
61will automatically execute `gclient runhooks` at the end.
62
63When `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:
66
67```shell
68$ cd src
69```
70
71### Converting an existing Linux checkout
72
73If you have an existing Linux checkout, you can add Android support by
74appending `target_os = ['android']` to your `.gclient` file (in the
75directory above `src`):
76
77```shell
78$ echo "target_os = [ 'android' ]" >> ../.gclient
79```
80
81Then run `gclient sync` to pull the new Android dependencies:
82
83```shell
84$ gclient sync
85```
86
87(This is the only difference between `fetch android` and `fetch chromium`.)
88
89### Install additional build dependencies
90
91Once you have checked out the code, run
92
93```shell
94$ build/install-build-deps-android.sh
95```
96
97to get all of the dependencies you need to build on Linux, *plus* all of the
98Android-specific dependencies (you need some of the regular Linux dependencies
99because an Android build includes a bunch of the Linux tools and utilities).
100
101### Run the hooks
102
103Once you've run `install-build-deps` at least once, you can now run the
104Chromium-specific hooks, which will download additional binaries and other
105things you might need:
106
107```shell
108$ gclient runhooks
109```
110
111*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.
115
116## Setting up the build
117
Tom Bridgwatereef401542018-08-17 00:54:43118Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
119a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
120to generate `.ninja` files. You can create any number of *build directories*
121with different configurations. To create a build directory which builds Chrome
122for Android, run:
dprankec641a5342017-04-04 02:35:01123
124```shell
125$ gn gen --args='target_os="android" is_chromecast=true' out/Default
126```
127
128* You only have to run this once for each new build directory, Ninja will
129 update the build files as needed.
130* You can replace `Default` with another name, but
131 it should be a subdirectory of `out`.
132* For other build arguments, including release settings, see [GN build
133 configuration](https://www.chromium.org/developers/gn-build-configuration).
134 The default will be a debug component build matching the current host
135 operating system and CPU.
136* For more info on GN, run `gn help` on the command line or read the
137 [quick start guide](../tools/gn/docs/quick_start.md).
138
139Also be aware that some scripts (e.g. `tombstones.py`, `adb_gdb.py`)
140require you to set `CHROMIUM_OUTPUT_DIR=out/Default`.
141
142## Build cast\_shell\_apk
143
Andrew Grievec81af4a2017-07-26 18:02:13144Build `cast_shell_apk` with Ninja using the command:
dprankec641a5342017-04-04 02:35:01145
146```shell
Dirk Pranke8bd55f22018-10-24 21:22:10147$ autoninja -C out/Default cast_shell_apk
dprankec641a5342017-04-04 02:35:01148```
149
Dirk Pranke8bd55f22018-10-24 21:22:10150(`autoninja` is a wrapper that automatically provides optimal values for the
151arguments passed to `ninja`.)
152
Andrew Grievec81af4a2017-07-26 18:02:13153## Installing and Running `cast_shell_apk` on a device
dprankec641a5342017-04-04 02:35:01154
dprankec641a5342017-04-04 02:35:01155### Plug in your Android device
156
157Make sure your Android device is plugged in via USB, and USB Debugging
158is enabled.
159
160To enable USB Debugging:
161
162* Navigate to Settings \> About Phone \> Build number
163* Click 'Build number' 7 times
164* Now navigate back to Settings \> Developer Options
165* Enable 'USB Debugging' and follow the prompts
166
167You may also be prompted to allow access to your PC once your device is
168plugged in.
169
170You can check if the device is connected by running:
171
172```shell
173third_party/android_tools/sdk/platform-tools/adb devices
174```
175
176Which prints a list of connected devices. If not connected, try
177unplugging and reattaching your device.
178
179### Build the APK
180
181```shell
Dirk Pranke8bd55f22018-10-24 21:22:10182autoninja -C out/Release cast_shell_apk
dprankec641a5342017-04-04 02:35:01183```
184
185And deploy it to your Android device:
186
187```shell
Andrew Grievec81af4a2017-07-26 18:02:13188out/Default/bin/cast_shell_apk install
189# Or to install and run:
190out/Default/bin/cast_shell_apk run "http://google.com"
dprankec641a5342017-04-04 02:35:01191```
192
193The app will appear on the device as "Chromium".
194
dprankec641a5342017-04-04 02:35:01195### Testing
196
Philip Jägenstedt17f89962017-05-18 08:25:54197For information on running tests, see [Android Test Instructions](android_test_instructions.md).