-
Notifications
You must be signed in to change notification settings - Fork 42
How to build chromium for Android
- A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly recommended.
- At least 100GB of free disk space.
- You must have Git and Python v2 installed already.
Most development is done on Ubuntu. Other distros may or may not work; see the Linux instructions for some suggestions.
Building the Android client on Windows or Mac is not supported and doesn't work.
-
Clone the depot_tools repository:
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
-
Add depot_tools to the end of your PATH (you will probably want to put this in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools to /path/to/depot_tools:
$ export PATH="$PATH:/path/to/depot_tools"
-
When cloning depot_tools to your home directory do not use ~ on PATH, otherwise
gclient runhooks
will fail to run. Rather, you should use either $HOME or the absolute path:
$ export PATH="$PATH:${HOME}/depot_tools"
-
Create a chromium directory for the checkout and change to it (you can call this whatever you like and put it wherever you like, as long as the full path has no spaces):
$ mkdir chromium && cd chromium
-
Clone the chromium-src repository:
$ git clone https://github.com/otcshare/chromium-src.git
-
Create .gclient file and edit the file to contain the following arguments:
$ vim .gclient
solutions = [
{
"url": "http://github.com/otcshare/chromium-src.git@webml",
"managed": False,
"name": "chromium-src",
"deps_file": ".DEPS.git",
"custom_deps": {},
},
]
target_os = [ 'android' ]
-
Make sure the proxy settings is correct in terminal:
$ export http_proxy=http://proxy_addr:proxy_port
$ export https_proxy=https://proxy_addr:proxy_port
-
Create .boto file and edit the file to contain the following arguments:
$ vim .boto
[boto]
proxy=http://proxy_addr
proxy_port=proxy_port
-
Add .boto config to system enviroment:
$ export NO_AUTH_BOTO_CONFIG="/path/to/.boto"
-
The remaining instructions assume you have switched to the chromium-src directory:
$ cd chromium-src
-
Then run gclient sync to pull the new Android dependencies:
$ gclient sync
- Once you have checked out the code, run:
$ build/install-build-deps-android.sh
to get all of the dependencies you need to build on Linux, plus all of the Android-specific dependencies (you need some of the regular Linux dependencies because an Android build includes a bunch of the Linux tools and utilities).
- Once you've run install-build-deps at least once, you can now run the Chromium-specific hooks, which will download additional binaries and other things you might need:
$ gclient runhooks
Optional: You can also install API keys if you want your build to talk to some Google services, but this is not necessary for most development and testing purposes.
-
Chromium uses Ninja as its main build tool along with a tool called GN to generate .ninja files. You can create any number of build directories with different configurations. To create a build directory, run:
$ gn gen out/Default
-
To config the flags for WebNN, run gn args out/Default and edit the file to contain the following arguments:
$ gn args out/Default
target_os = "android"
target_cpu = "arm64" # See "Figuring out target_cpu" below
is_debug = false
is_component_build = false
-
The value of target_cpu determines what instruction set to use for native code. Given a device (or emulator), you can determine the correct instruction set with adb shell getprop ro.product.cpu.abi:
getprop ro.product.cpu.abi output target_cpu value armeabi-v7a arm arm64-v8a arm64 x86_64 x64 x86 x86 arm and x86 may optionally be used instead of arm64 and x64 for non-WebView targets. This is also allowed for Monochrome, but only when not set as WebView the provider.
-
Build Chromium with Ninja using the command:
$ autoninja -C out/Default chrome_public_apk
You can get a list of all of the other build targets from GN by running gn ls out/Default from the command line. To compile one, pass the GN label to Ninja with no preceding “//” (so, for //chrome/test:unit_tests use autoninja -C out/Default chrome/test:unit_tests).