1 Building Android binary
2 =======================
4 In this article, we briefly describe how to build Android binary using
5 `Android NDK <http://developer.android.com/tools/sdk/ndk/index.html>`_
6 cross-compiler on Debian Linux.
8 The easiest way to build android binary is use Dockerfile.android.
9 See Dockerfile.android for more details. If you cannot use
10 Dockerfile.android for whatever reason, continue to read the rest of
13 We offer ``android-config`` and ``android-make`` scripts to make the
14 build easier. To make these script work, NDK toolchain must be
15 installed in the following way. First, let us introduce
16 ``ANDROID_HOME`` environment variable. We need to install toolchain
17 under ``$ANDROID_HOME/toolchain``. An user can freely choose the path
18 for ``ANDROID_HOME``. For example, to install toolchain under
19 ``$ANDROID_HOME/toolchain``, do this in the the directory where NDK is
22 $ build/tools/make-standalone-toolchain.sh \
23 --install-dir=$ANDROID_HOME/toolchain \
24 --toolchain=arm-linux-androideabi-4.9 \
28 The additional flag ``--system=linux-x86_64`` may be required if you
29 are using x86_64 system.
31 The platform level is not important here because we don't use Android
34 The dependent libraries, such as OpenSSL and libev should be built
35 with the toolchain and installed under ``$ANDROID_HOME/usr/local``.
36 We recommend to build these libraries as static library to make the
37 deployment easier. libxml2 support is currently disabled.
39 We use zlib which comes with Android NDK, so we don't have to build it
42 If SPDY support is required for nghttpx and h2load, build and install
45 Before running ``android-config`` and ``android-make``,
46 ``ANDROID_HOME`` environment variable must be set to point to the
47 correct path. Also add ``$ANDROID_HOME/toolchain/bin`` to ``PATH``::
49 $ export PATH=$PATH:$ANDROID_HOME/toolchain/bin
51 To configure OpenSSL, use the following script:
57 if [ -z "$ANDROID_HOME" ]; then
58 echo 'No $ANDROID_HOME specified.'
61 PREFIX=$ANDROID_HOME/usr/local
62 TOOLCHAIN=$ANDROID_HOME/toolchain
63 PATH=$TOOLCHAIN/bin:$PATH
65 export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi-
66 ./Configure --prefix=$PREFIX android
68 And run ``make install`` to build and install.
70 We cannot compile libev without modification. Apply `this patch
71 <https://gist.github.com/tatsuhiro-t/48c45f08950f587180ed>`_ before
72 configuring libev. This patch is for libev-4.19. After applying the
73 patch, to configure libev, use the following script:
79 if [ -z "$ANDROID_HOME" ]; then
80 echo 'No $ANDROID_HOME specified.'
83 PREFIX=$ANDROID_HOME/usr/local
84 TOOLCHAIN=$ANDROID_HOME/toolchain
85 PATH=$TOOLCHAIN/bin:$PATH
88 --host=arm-linux-androideabi \
89 --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
93 CPPFLAGS=-I$PREFIX/include \
96 And run ``make install`` to build and install.
98 To configure spdylay, use the following script:
102 if [ -z "$ANDROID_HOME" ]; then
103 echo 'No $ANDROID_HOME specified.'
106 PREFIX=$ANDROID_HOME/usr/local
107 TOOLCHAIN=$ANDROID_HOME/toolchain
108 PATH=$TOOLCHAIN/bin:$PATH
112 --host=arm-linux-androideabi \
113 --build=`dpkg-architecture -qDEB_BUILD_GNU_TYPE` \
118 CPPFLAGS="-I$PREFIX/include" \
119 PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" \
120 LDFLAGS="-L$PREFIX/lib"
122 And run ``make install`` to build and install. After spdylay
123 installation, edit $ANDROID_HOME/usr/local/lib/pkgconfig/libspdylay.pc
124 and remove the following line::
126 Requires.private: zlib
128 After prerequisite libraries are prepared, run ``android-config`` and
129 then ``android-make`` to compile nghttp2 source files.
131 If all went well, application binaries, such as nghttpx, are created
132 under src directory. Strip debugging information from the binary
133 using the following command::
135 $ arm-linux-androideabi-strip src/nghttpx