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.
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.
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:
This will create the
The next step is to download the Android source code. In the
This will take a while to complete.
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
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:
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.
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 Android.mk 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.
Follow the Android build instructions. These will most likely boil down to:
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:
Again, if the device has already been flashed with a correct system image it is possible to only update the changed files:
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:
Alternatively, you may wish to manually inspect that manifest file and only alter selected projects (usually
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:
To sync the Chromium tree simply follow the instructions for updating the code in the
Remember to regenerate the Android.mk files after you sync the Chromium code:
To update the Android tree run the following command in the
This section describes common scenarios where the android_aosp bot (which is supposed to keep this workflow working) might break:
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..).
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 R.java resource maps count as the "public" API so touching those can break the bot.