This document contains step-by-step instructions for building a Chromium-powered Android WebView.
Chromium's build process is a bit fussy, and the Android target is even more fussy, so the least painful way of getting it done is to set up a VM with the exact software that the build process was designed for. The steps below accomplish this.
-
Get the 64-bit ISO for Ubuntu Server 12.10.
- Go to http://releases.ubuntu.com/12.10/
- Get the
64-bit PC (AMD64) server install image
-
Set up a VirtualBox VM.
- Name: ChromeWebView
- Type: Linux
- Version: Ubuntu 64-bit
- RAM: 4096Mb
- Disk: VDI, dynamic, 40Gb
-
Change the settings (Machine > Settings in the VirtualBox menu)
- System > Processor > Processor(s): 4 (number of CPU cores on your machine)
- Audio > uncheck Enable Audio
- Network > Adapter 1 > Advanced > Adapter Type: virtio-net
- Network > Adapter 2
- check Enable network adapter
- Attached to > Host-only Adapter
- Advanced > Adapter Type: virtio-net
- Ports > USB > uncheck Enable USB 2.0 (EHCI) Controller
-
Start VM and set up the server.
- Select the Ubuntu ISO downloaded earlier.
- Start a server installation, providing default answers, except:
- Hostname: crbuild
- Full name: crbuild
- Username: crbuild
- Password: crbuild
- Confirm using a weak password
- Encrypt home directory: no
- Partitioning: Guided - use entire disk (no LVM or encryption)
- Software to install: OpenSSH server
-
After the VM restarts, set up networking.
- Log in using the VM console.
- Open /etc/network/interfaces in a text editor (sudo vim ...)
- Duplicate the "primary network interface" section
- In the duplicate section, replace-all eth0 with eth1, primary with secondary
- Save the file.
sudo apt-get install -y avahi-daemon
sudo reboot
-
Prepare to SSH into the VM.
- If you don't have an ssh key
ssh-keygen -t rsa
- press Enter all the way (default key type, no passphrase)
ssh-copy-id crbuild@crbuild.local ssh crbuild@crbuild.local sudo sh -c "echo crbuild ALL=NOPASSWD: ALL >> /etc/sudoers"
- If you don't have an ssh key
-
Install Depot Tools.
sudo apt-get update && sudo apt-get -y upgrade sudo apt-get -y install git git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git echo "export PATH=$PATH:$HOME/depot_tools" >> ~/.bashrc source ~/.bashrc
-
Get the Oracle Java 6 JDK.
- Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Search for "Java SE 6", click on JDK
- Click on the radio button for accepting the license
- Download the Linux x86 non-RPM file (jdk-6uNN-linux-x64.bin)
exit # Get out of the VM ssh session, run this on the host. scp ~/Downloads/jdk-6u*-linux-x64.bin crbuild@crbuild.local:~/jdk6.bin ssh crbuild@crbuild.local # Get back into the VM ssh session. sudo mkdir /usr/lib/jvm cd /usr/lib/jvm sudo /bin/sh ~/jdk6.bin -noregister rm ~/jdk6.bin sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_*/bin/javac 50000 sudo update-alternatives --config javac sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_*/bin/java 50000 sudo update-alternatives --config java sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_*/bin/javaws 50000 sudo update-alternatives --config javaws sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.6.0_*/bin/javap 50000 sudo update-alternatives --config javap sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_*/bin/jar 50000 sudo update-alternatives --config jar cd ~/
-
Get the Chromium source code and dependencies.
- Document: http://dev.chromium.org/developers/how-tos/get-the-code
- Document: https://code.google.com/p/chromium/wiki/LinuxBuildInstructions
- Document: https://code.google.com/p/chromium/wiki/AndroidBuildInstructions
# ssh crbuild@crbuild.local sudo apt-get install -y subversion sudo apt-get install -y ia32-libs libc6-dev-i386 g++-multilib mkdir ~/chromium cd ~/chromium gclient config https://src.chromium.org/chrome/trunk/src \ https://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/LAST_CHANGE svn ls https://src.chromium.org/chrome # Permanently accept the SSL certificate, if necessary. echo "target_os = ['android']" >> .gclient gclient sync --nohooks sudo ./src/build/install-build-deps-android.sh sudo ./src/build/install-build-deps.sh # Debugging symbols are not necessary. . build/android/envsetup.sh # There is no / between . and build. gclient runhooks
-
Build the Chromium library.
# ssh crbuild@crbuild.local cd ~/chromium/src . build/android/envsetup.sh # There is no / between . and build. android_gyp ninja -C out/Release -j4 content_shell_apk # Number of CPU cores after -j. ninja -C out/Release -j4 chromium_testshell # Number of CPU cores after -j. ninja -C out/Release -j4 libwebviewchromium # Number of CPU cores after -j.
# ssh crbuild@crbuild.local
sudo apt-get update && sudo apt-get -y dist-upgrade
cd ~/chromium/
gclient sync
cd ~/chromium/src
. build/android/envsetup.sh # There is no / between . and build.
android_gyp
ninja -C out/Release -j4 content_shell_apk # Number of CPU cores after -j.
ninja -C out/Release -j4 chromium_testshell # Number of CPU cores after -j.
ninja -C out/Release -j4 libwebviewchromium # Number of CPU cores after -j.