blob: 3a89b7ea5085a74d7c9ea38051f6143e6950b0e9 [file] [log] [blame] [view]
Albert J. Wong08d97f592017-08-23 21:56:311# Android Dev Tips
2
3Just an internal tips page for people working on the memory team.
4
5[TOC]
6
7## Building clank
8
9See instructions on the official [android build
10page](/docs/android_build_instructions.md) for the most up to date info.
11However, it will tell you how to build _everything_ which is way way more than
12you need and way way harder. In short, you mostly need to do 3 (well, 2)
13things:
14
15 1. Create a gn out directory with `target_os="android"` in the GN args
16 2. Disable NaCl. (not strictly necessary, but it makes Albert feel better)
17 3. Build the `chrome_public_apk`
18
19## Too much text! I just want to run my thing!
20
21Fine fine. First, ensure only one phone is attached. If you have multiple,
22you'll need to pass the device ID everywhere. Also, despite common wisdom, you
23do NOT have to root your phone. Anyways...here's command lines to copy-🍝.
24
25Get your environment setup (adb in your path, etc):
26```
27$ source build/android/envsetup.sh
28```
29
30Incremental build/deploy:
31```
32$ ninja -C out/clank -j1000 chrome_public_apk && ./build/android/adb_install_apk.py --keep_data out/clank/apks/ChromePublic.apk && ( ./build/android/adb_kill_chrome_public ; ./build/android/adb_run_chrome_public )
33
34```
35
36Setting flags (**see next part!**):
37```
38$ ./build/android/adb_chrome_public_command_line --my-happy-flag-here
39
40```
41
42Select chromium as the system debug app to pick up flags!:
43 * Go to the `Developer Options` in Android Settings
44 * Find the `Select debug app` option.
45 * Select Chromium (after your first install)
46
47If you neglect to do this AND you do not have a rooted phone, the
48`adb_chrome_public_command_line` tool cannot write a command line file into the
49right location for your Chrome binary to read. When in doubt, verify the flags
50in `about://version`.
51
52
53## What is `chrome_public_apk`?
54
55This seems to be the Android moral equivalent of the the `chrome` target on
56desktop. It builds the APK that you want to install on your phone to run your
57version of chromium.
58
59
60## Running logcat without going crazy.
61
62Logcat dumps a lot of system messages on periodic timers which can be noisy.
63Often you just want to look at stack traces and things from chrome logs. This
64can be filtered with a command like the following:
65
66```
67adb logcat -s chromium:* ActivityManager:* WindowManager:* libc:* DEBUG:* System.err:*
68```
69
70The `-s` silences everything that's not explicitly listed by default.
71`ActivityManager` shows the android life-cycle events for Chrome. `WindowManager`
72shows window changes. `libc` and `DEBUG` show stack traces. `System.err` is the
73Java interpretation of the C failures. And `chromium` is obviously the bulk of
74the interesting messages.
75
76## Running telemetry (aka `./tools/perf/run_benchmark`)
77
78Passing in `--device=` with the correct id from `adb devices` will make the
79script talk to your phone. You will need to go to the `Developer Options` and
80force the screen to not lock. Then you can select the executable to run with
81one of:
82
83```
84--browser=exact --browser-executable=out/clank/apks/ChromePublic.apk
85```
86
87or if you want to run something already installed on the phone, there's a set of
88nifty options to `--browser` like:
89
90```
91--browser=android-chrome-chrome
92--browser=android-chrome-beta
93--browser=android-chrome-dev
94--browser=android-chrome-canary
95--browser=android-chrome-chromium
96```