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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 echo "{ 'GYP_DEFINES': 'OS=android target_arch=arm', }" > chromium.gyp_env | 68 echo "{ 'GYP_DEFINES': 'OS=android target_arch=arm', }" > chromium.gyp_env |
69 ``` | 69 ``` |
70 | 70 |
71 Note that "arm" is the default architecture and can be omitted. If | 71 Note that "arm" is the default architecture and can be omitted. If |
72 building for x86 or MIPS devices, change `target_arch` to "ia32" or | 72 building for x86 or MIPS devices, change `target_arch` to "ia32" or |
73 "mipsel". | 73 "mipsel". |
74 | 74 |
75 **NOTE:** If you are using the `GYP_DEFINES` environment variable, it | 75 **NOTE:** If you are using the `GYP_DEFINES` environment variable, it |
76 will override any settings in this file. Either clear it or set it to | 76 will override any settings in this file. Either clear it or set it to |
77 the values above before running `gclient runhooks`. | 77 the values above before running `gclient runhooks`. |
| 78 |
| 79 See |
| 80 [build/android/developer\_recommended\_flags.gypi](https://code.google.com/p/chr
omium/codesearch#chromium/src/build/android/developer_recommended_flags.gypi&sq=
package:chromium&type=cs&q=file:android/developer_recommended_flags.gypi&l=1) |
| 81 for other recommended GYP settings. |
| 82 Once chromium.gyp_env is ready, you need to run the following command |
| 83 to update projects from gyp files. You may need to run this again when |
| 84 you have added new files, updated gyp files, or sync'ed your |
| 85 repository. |
| 86 |
| 87 ```shell |
| 88 gclient runhooks |
| 89 ``` |
| 90 |
| 91 #### This will download more things and prompt you to accept Terms of Service fo
r Android SDK packages. |
| 92 |
| 93 ## Configure GN (recommended) |
| 94 |
| 95 If you are using GN, create a build directory and set the build flags |
| 96 with: |
| 97 |
| 98 ```shell |
| 99 gn args out/Default |
| 100 ``` |
| 101 |
| 102 You can replace out/Default with another name you choose inside the out |
| 103 directory. Do not use GYP's out/Debug or out/Release directories, as |
| 104 they may conflict with GYP builds. |
| 105 |
| 106 Also be aware that some scripts (e.g. tombstones.py, adb_gdb.py) |
| 107 require you to set `CHROMIUM_OUTPUT_DIR=out/Default`. |
| 108 |
| 109 This command will bring up your editor with the GN build args. In this |
| 110 file add: |
| 111 |
| 112 ``` |
| 113 target_os = "android" |
| 114 target_cpu = "arm" # (default) |
| 115 is_debug = true # (default) |
| 116 |
| 117 # Other args you may want to set: |
| 118 is_component_build = true |
| 119 is_clang = true |
| 120 symbol_level = 1 # Faster build with fewer symbols. -g1 rather than -g2 |
| 121 enable_incremental_javac = true # Much faster; experimental |
| 122 symbol_level = 1 # Faster build with fewer symbols. -g1 rather than -g2 |
| 123 enable_incremental_javac = true # Much faster; experimental |
| 124 ``` |
| 125 |
| 126 You can also specify `target_cpu` values of "x86" and "mipsel". Re-run |
| 127 gn args on that directory to edit the flags in the future. See the [GN |
| 128 build |
| 129 configuration](https://www.chromium.org/developers/gn-build-configuration) |
| 130 page for other flags you may want to set. |
| 131 |
| 132 ### Install build dependencies |
| 133 |
| 134 Update the system packages required to build by running: |
| 135 |
| 136 ```shell |
| 137 ./build/install-build-deps-android.sh |
| 138 ``` |
| 139 |
| 140 Make also sure that OpenJDK 1.7 is selected as default: |
| 141 |
| 142 `sudo update-alternatives --config javac` |
| 143 `sudo update-alternatives --config java` |
| 144 `sudo update-alternatives --config javaws` |
| 145 `sudo update-alternatives --config javap` |
| 146 `sudo update-alternatives --config jar` |
| 147 `sudo update-alternatives --config jarsigner` |
| 148 |
| 149 ### Synchronize sub-directories. |
| 150 |
| 151 ```shell |
| 152 gclient sync |
| 153 ``` |
| 154 |
| 155 ## Build and install the APKs |
| 156 |
| 157 If the `adb_install_apk.py` script below fails, make sure aapt is in |
| 158 your PATH. If not, add aapt's path to your PATH environment variable (it |
| 159 should be |
| 160 `/path/to/src/third_party/android_tools/sdk/build-tools/{latest_version}/`). |
| 161 |
| 162 Prepare the environment: |
| 163 |
| 164 ```shell |
| 165 . build/android/envsetup.sh |
| 166 ``` |
| 167 |
| 168 ### Plug in your Android device |
| 169 |
| 170 Make sure your Android device is plugged in via USB, and USB Debugging |
| 171 is enabled. |
| 172 |
| 173 To enable USB Debugging: |
| 174 |
| 175 * Navigate to Settings \> About Phone \> Build number |
| 176 * Click 'Build number' 7 times |
| 177 * Now navigate back to Settings \> Developer Options |
| 178 * Enable 'USB Debugging' and follow the prompts |
| 179 |
| 180 You may also be prompted to allow access to your PC once your device is |
| 181 plugged in. |
| 182 |
| 183 You can check if the device is connected by running: |
| 184 |
| 185 ```shell |
| 186 third_party/android_tools/sdk/platform-tools/adb devices |
| 187 ``` |
| 188 |
| 189 Which prints a list of connected devices. If not connected, try |
| 190 unplugging and reattaching your device. |
OLD | NEW |