OLD | NEW |
1 # Android Build Instructions | 1 # Android Build Instructions |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Prerequisites | 5 ## Prerequisites |
6 | 6 |
7 A Linux build machine capable of building [Chrome for | 7 A Linux build machine capable of building [Chrome for |
8 Linux](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_
instructions_prerequisites.md). | 8 Linux](https://chromium.googlesource.com/chromium/src/+/master/docs/linux_build_
instructions_prerequisites.md). |
9 Other (Mac/Windows) platforms are not supported for Android. | 9 Other (Mac/Windows) platforms are not supported for Android. |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 plugged in. | 181 plugged in. |
182 | 182 |
183 You can check if the device is connected by running: | 183 You can check if the device is connected by running: |
184 | 184 |
185 ```shell | 185 ```shell |
186 third_party/android_tools/sdk/platform-tools/adb devices | 186 third_party/android_tools/sdk/platform-tools/adb devices |
187 ``` | 187 ``` |
188 | 188 |
189 Which prints a list of connected devices. If not connected, try | 189 Which prints a list of connected devices. If not connected, try |
190 unplugging and reattaching your device. | 190 unplugging and reattaching your device. |
| 191 |
| 192 ### Build the full browser |
| 193 |
| 194 **Note: When adding new resource files or java files in gyp builds, you |
| 195 need to run 'gclient runhooks' again to get them in the build.** |
| 196 |
| 197 ```shell |
| 198 ninja -C out/Release chrome_public_apk |
| 199 ``` |
| 200 |
| 201 And deploy it to your Android device: |
| 202 |
| 203 ```shell |
| 204 build/android/adb_install_apk.py out/Release/apks/ChromePublic.apk # For gyp. |
| 205 CHROMIUM_OUTPUT_DIR=$gndir build/android/adb_install_apk.py $gndir/apks/ChromePu
blic.apk # for gn. |
| 206 ``` |
| 207 |
| 208 The app will appear on the device as "Chromium". |
| 209 |
| 210 ### Build Content shell |
| 211 |
| 212 Wraps the content module (but not the /chrome embedder). See |
| 213 [http://www.chromium.org/developers/content-module](http://www.chromium.org/deve
lopers/content-module) |
| 214 for details on the content module and content shell. |
| 215 |
| 216 ```shell |
| 217 ninja -C out/Release content_shell_apk |
| 218 build/android/adb_install_apk.py out/Release/apks/ContentShell.apk |
| 219 ``` |
| 220 |
| 221 this will build and install an Android apk under |
| 222 `out/Release/apks/ContentShell.apk`. For GYP, replace `Release` with `Debug` |
| 223 above if you want to generate a Debug app. If you are using GN, substitute the |
| 224 name you initially gave to your build directory. |
| 225 |
| 226 If you use custom out dir instead of standard out/ dir, use |
| 227 CHROMIUM_OUT_DIR env. |
| 228 |
| 229 ```shell |
| 230 export CHROMIUM_OUT_DIR=out_android |
| 231 ``` |
| 232 |
| 233 ### Build WebView shell |
| 234 |
| 235 [Android WebView](http://developer.android.com/reference/android/webkit/WebView.
html) |
| 236 is a system framework component. Since Android KitKat, it is implemented using |
| 237 Chromium code (based off the [content module](http://dev.chromium.org/developers
/content-module)). |
| 238 It is possible to test modifications to WebView using a simple test shell. The |
| 239 WebView shell is a view with a URL bar at the top (see [code](https://code.googl
e.com/p/chromium/codesearch#chromium/src/android_webview/test/shell/src/org/chro
mium/android_webview/test/AwTestContainerView.java)) |
| 240 and is **independent** of the WebView **implementation in the Android system** ( |
| 241 the WebView shell is essentially a standalone unbundled app). |
| 242 As drawback, the shell runs in non-production rendering mode only. |
| 243 |
| 244 ```shell |
| 245 ninja -C out/Release android_webview_apk |
| 246 build/android/adb_install_apk.py out/Release/apks/AndroidWebView.apk |
| 247 ``` |
| 248 |
| 249 If, instead, you want to build the complete Android WebView framework component
and test the effect of your chromium changes in other Android app using the WebV
iew, you should follow the [Android AOSP + chromium WebView instructions](http:/
/www.chromium.org/developers/how-tos/build-instructions-android-webview) |
| 250 |
| 251 ### Running |
| 252 |
| 253 Set [command line flags](https://www.chromium.org/developers/how-tos/run-chromiu
m-with-flags) if necessary. |
| 254 |
| 255 For Content shell: |
| 256 |
| 257 ```shell |
| 258 build/android/adb_run_content_shell http://example.com |
| 259 ``` |
| 260 |
| 261 For Chrome public: |
| 262 |
| 263 ```shell |
| 264 build/android/adb_run_chrome_public http://example.com |
| 265 ``` |
| 266 |
| 267 For Android WebView shell: |
| 268 |
| 269 ```shell |
| 270 build/android/adb_run_android_webview_shell http://example.com |
| 271 ``` |
| 272 |
| 273 ### Logging and debugging |
| 274 |
| 275 Logging is often the easiest way to understand code flow. In C++ you can print |
| 276 log statements using the LOG macro or printf(). In Java, you can print log |
| 277 statements using [android.util.Log](http://developer.android.com/reference/andro
id/util/Log.html): |
| 278 |
| 279 `Log.d("sometag", "Reticulating splines progress = " + progress);` |
| 280 |
| 281 You can see these log statements using adb logcat: |
| 282 |
| 283 ```shell |
| 284 adb logcat...01-14 11:08:53.373 22693 23070 D sometag: Reticulating splines prog
ress = 0.99 |
| 285 ``` |
| 286 |
| 287 You can debug Java or C++ code. To debug C++ code, use one of the |
| 288 following commands: |
| 289 |
| 290 ```shell |
| 291 build/android/adb_gdb_content_shell |
| 292 build/android/adb_gdb_chrome_public |
| 293 build/android/adb_gdb_android_webview_shell http://example.com |
| 294 ``` |
| 295 |
| 296 See [Debugging Chromium on Android](https://www.chromium.org/developers/how-tos/
debugging-on-android) |
| 297 for more on debugging, including how to debug Java code. |
| 298 |
| 299 ### Testing |
| 300 |
| 301 For information on running tests, see [android\_test\_instructions.md](https://c
hromium.googlesource.com/chromium/src/+/master/docs/android_test_instructions.md
). |
| 302 |
| 303 ### Faster Edit/Deploy (GN only) |
| 304 |
| 305 GN's "incremental install" uses reflection and side-loading to speed up the edit |
| 306 & deploy cycle (normally < 10 seconds). |
| 307 |
| 308 * Make sure to set` is_component_build = true `in your GN args |
| 309 * All apk targets have \*`_incremental` targets defined (e.g. |
| 310 `chrome_public_apk_incremental`) |
| 311 |
| 312 Here's an example: |
| 313 |
| 314 ```shell |
| 315 ninja -C out/Default chrome_public_apk_incremental |
| 316 out/Default/bin/install_chrome_public_apk_incremental -v |
| 317 ``` |
| 318 |
| 319 For gunit tests (note that run_*_incremental automatically add |
| 320 --fast-local-dev when calling test\_runner.py): |
| 321 |
| 322 ```shell |
| 323 ninja -C out/Default base_unittests_incremental |
| 324 out/Default/bin/run_base_unittests_incremental |
| 325 ``` |
| 326 |
| 327 For instrumentation tests: |
| 328 |
| 329 ```shell |
| 330 ninja -C out/Default chrome_public_test_apk_incremental |
| 331 out/Default/bin/run_chrome_public_test_apk_incremental |
| 332 ``` |
| 333 |
| 334 To uninstall: |
| 335 |
| 336 ```shell |
| 337 out/Default/bin/install_chrome_public_apk_incremental -v --uninstall |
| 338 ``` |
| 339 |
| 340 ### Miscellaneous |
| 341 |
| 342 #### Rebuilding libchrome.so for a particular release |
| 343 |
| 344 In the case where you want to modify the native code for an existing |
| 345 release of Chrome for Android (v25+) you can do the following steps. |
| 346 Note that in order to get your changes into the official release, you'll |
| 347 need to send your change for a codereview using the regular process for |
| 348 committing code to chromium. |
| 349 |
| 350 1. Open Chrome on your Android device and visit chrome://version |
| 351 2. Copy down the id listed next to "Build ID:" |
| 352 3. Go to |
| 353 [http://storage.googleapis.com/chrome-browser-components/BUILD\_ID\_FROM\_ST
EP\_2/index.html](http://storage.googleapis.com/chrome-browser-components/BUILD_
ID_FROM_STEP_2/index.html) |
| 354 4. Download the listed files and follow the steps in the README. |
OLD | NEW |