Albert J. Wong | 08d97f59 | 2017-08-23 21:56:31 | [diff] [blame] | 1 | # Android Dev Tips |
| 2 | |
| 3 | Just an internal tips page for people working on the memory team. |
| 4 | |
| 5 | [TOC] |
| 6 | |
| 7 | ## Building clank |
| 8 | |
| 9 | See instructions on the official [android build |
| 10 | page](/docs/android_build_instructions.md) for the most up to date info. |
| 11 | However, it will tell you how to build _everything_ which is way way more than |
| 12 | you need and way way harder. In short, you mostly need to do 3 (well, 2) |
| 13 | things: |
| 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 | |
| 21 | Fine fine. First, ensure only one phone is attached. If you have multiple, |
| 22 | you'll need to pass the device ID everywhere. Also, despite common wisdom, you |
| 23 | do NOT have to root your phone. Anyways...here's command lines to copy-🍝. |
| 24 | |
| 25 | Get your environment setup (adb in your path, etc): |
| 26 | ``` |
| 27 | $ source build/android/envsetup.sh |
| 28 | ``` |
| 29 | |
| 30 | Incremental 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 | |
| 36 | Setting flags (**see next part!**): |
| 37 | ``` |
| 38 | $ ./build/android/adb_chrome_public_command_line --my-happy-flag-here |
| 39 | |
| 40 | ``` |
| 41 | |
| 42 | Select 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 | |
| 47 | If 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 |
| 49 | right location for your Chrome binary to read. When in doubt, verify the flags |
| 50 | in `about://version`. |
| 51 | |
| 52 | |
| 53 | ## What is `chrome_public_apk`? |
| 54 | |
| 55 | This seems to be the Android moral equivalent of the the `chrome` target on |
| 56 | desktop. It builds the APK that you want to install on your phone to run your |
| 57 | version of chromium. |
| 58 | |
| 59 | |
| 60 | ## Running logcat without going crazy. |
| 61 | |
| 62 | Logcat dumps a lot of system messages on periodic timers which can be noisy. |
| 63 | Often you just want to look at stack traces and things from chrome logs. This |
| 64 | can be filtered with a command like the following: |
| 65 | |
| 66 | ``` |
| 67 | adb logcat -s chromium:* ActivityManager:* WindowManager:* libc:* DEBUG:* System.err:* |
| 68 | ``` |
| 69 | |
| 70 | The `-s` silences everything that's not explicitly listed by default. |
| 71 | `ActivityManager` shows the android life-cycle events for Chrome. `WindowManager` |
| 72 | shows window changes. `libc` and `DEBUG` show stack traces. `System.err` is the |
| 73 | Java interpretation of the C failures. And `chromium` is obviously the bulk of |
| 74 | the interesting messages. |
| 75 | |
| 76 | ## Running telemetry (aka `./tools/perf/run_benchmark`) |
| 77 | |
| 78 | Passing in `--device=` with the correct id from `adb devices` will make the |
| 79 | script talk to your phone. You will need to go to the `Developer Options` and |
| 80 | force the screen to not lock. Then you can select the executable to run with |
| 81 | one of: |
| 82 | |
| 83 | ``` |
| 84 | --browser=exact --browser-executable=out/clank/apks/ChromePublic.apk |
| 85 | ``` |
| 86 | |
| 87 | or if you want to run something already installed on the phone, there's a set of |
| 88 | nifty 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 | ``` |