For Developers‎ > ‎How-Tos‎ > ‎

Build Instructions (Android WebView)


These are instructions for building the Android WebView in the Android source tree. These instructions are necessary if you wish to run the WebView code as an Android system component (which is useful when working on performance or application compatibility). To run tests and for certain development tasks it is sufficient to use the standalone test shell as described here.


A machine capable of building Android.

Being able to checkout and build Chrome for Android.

Getting the code

You will need to obtain both Android AOSP and Chromium source trees. Both take up quite a bit of disk space, so be prepared for that. In these instructions we will assume the following directory outlined below, this is to make the instructions clearer; mirroring this structure is not necessary for the build to work.

|- android

To get the Android code from AOSP we will use repo. repo is the Android repository management tool and you might want to read about it before proceeding. There is a version of repo bundled in depot_tools, however the version available here is usually newer and should be preferred for interacting with the Android tree.

First you should initialize repo:

cd code/android
repo init -u -b chromium-dev

This will create the code/android/.repo folder.

The next step is to download the Android source code. In the code/android folder run:

repo sync

This will take a while to complete.

Checkout Chromium source into the Android tree

If you already have a Chromium checkout that you would like to re-use for this workflow see the symlinking instructions below, otherwise you will need to check out the Chrome for Android source code into the code/android/external/chromium_org folder.

cd code/android/external/chromium_org
fetch android --nosvn=True # If you are a committer drop the --nosvn=True option

This will also take a while to complete.

Alternatively, only if you have already checked out a copy of the Chromium tree and wish to use that checkout for this workflow it's possible to symlink an existing copy of the Chromium source tree into the Android source tree:

ln -s /[absolute path to]/chromium/src /[absolute path to]/code/android/external/chromium_org/src

Again, the above step is only necessary if you have already checked our (or wish to check out) the Chromium source tree into a location separate from the Android source tree.

Generating files

In order to generate up to date Makefiles you will need to run the gyp tool. You will need to do this each time you sync the Chromium code or if you modify any *.gyp(i) files.

Note: The files generated for the Chromium tree will be ignored by git by default. This is correct, these files are not part of the Chromium source code (since they can always be generated from the *.gyp(i) files) and should not be added to any patches you might send out.

cd code/android
. build/
lunch [your_lunch_flavor]
cd ./external/chromium_org/src


Follow the Android build instructions. These will most likely boil down to:

cd code/android
. build/ # You only need to do this once per shell.
lunch [your_lunch_flavor] # You only need to do this once per shell.
make -j [as_much_as_the_machine_can_take]

Iterating on the WebView code

Other than after performing a full sync of the Android tree it should be sufficient (and faster) to issue the following command to rebuild the WebView:

cd code/android
mmm frameworks/webview external/chromium_org -j [as_much_as_the_machine_can_take]

Again, if the device has already been flashed with a correct system image it is possible to only update the changed files:

adb remount
adb shell stop
adb sync system
adb shell start

The relationship between Chromium revisions and Android project revisions

Most of the time building in a checkout consisting of Tip-of-Tree Chromium and ToT Android will result in a successful build. Because of the nature of the process outlined below it is possible that for a brief period of time the two trees don't compile. It is also possible that you may wish to go back to a previous Chromium revision and need to update the Android sources to match.
To check out a version of the Android source tree which matches a particular Chromium revision (and therefore should always compile) you should:
cd code/android
repo sync -m /[absolute path to]/code/android/external/chromium_org/src/android_webview/buildbot/aosp_manifest.xml
Alternatively, you may wish to manually inspect that manifest file and only alter selected projects (usually frameworks/webview).

Contributing code

The process for contributing code depends on whether your changes need to go into the Chromium source tree or the Android tree. Some things to remember:

  • only the frameworks/webview and external/chromium_org projects in your Android tree are set up to take patches, trying to submit a patch anywhere else (like frameworks/base) will result in an error. This is intentional, if you need to submit patches to other projects then please use the AOSP master branch. If you have a CL to another project which you believe should be pulled into this workflow please talk to one of the chromium/android_webview/OWNERS before proceeding.
  • syncing, creating branches, uploading reviews for changes to the Android projects (frameworks/webview) is done by following the Android process (so using repo),
  • syncing, creating branches, uploading reviews for changes to the Chromium projects (everything under code/android/external/chromium_org/src) is done by following the Chromium process (so using gclient, git and git cl from depot_tools).

If your changes need to go into both Chromium and the frameworks/webview folder at the same time you will need to do the following:

  1. Upload both patches to the respective code review systems, submit them for review.
  2. Commit the Android change first, note the SHA1 at which it was merged.
  3. Update the revision field in the frameworks/webview project entry in the android_webview/buildbot/aosp_manifest.xml
    This should be an update to your original Chromium patch, not a separate CL (in other words, you land the Android change first, you land the Chromium change second).

Updating the code

To sync the Chromium tree simply follow the instructions for updating the code in the code/chromium folder.

Remember to regenerate the files after you sync the Chromium code:

cd code/chromium

To update the Android tree run the following command in the code/android folder :

repo sync

Common problems

This section describes common scenarios where the android_aosp bot (which is supposed to keep this workflow working) might break:

New dependency

    You've added an (in)direct dependency from the android_webview/ to a third_party library. You can hit this by adding deps to something the android_webview depends on (like content/ or net/ or base/, etc..).
solution: you need to add the new dep to android_webview/buildbot/
symptom: The bot is failing because it can't gyp or compile some source code that should be there (and is normally synced via DEPS).

android_webview API changes

    You modified the android_webview/ "public" Java API. In some rare cases we export content layer types as part of our public API so it's possible to hit this without touching code in the android_webview folder.Also some content/ Java resources and the resource maps count as the "public" API so touching those can break the bot.
symptom: the bot is failing to compile Java code from android-src/frameworks/webview complaining about missing types/fields/methods/etc..
solution: you need to update the code in AOSP to match. See the "Contributing Code" section above.