1.. _target-android: 2 3------- 4Android 5------- 6The Android target supports building Pigweed on devices using an Android 7Native Development Kit (NDK). 8 9.. warning:: 10 This target is under construction, not ready for use, and the documentation 11 is incomplete. 12 13Setup 14===== 15You must first download and unpack a copy of the `Android NDK`_ and let Pigweed 16know where that is located using the ``pw_android_toolchain_NDK_PATH`` build 17arg. 18 19.. _Android NDK: https://developer.android.com/ndk 20 21You can set Pigweed build options using ``gn args out``. 22 23Building 24======== 25To build for this Pigweed target, simply build the top-level "android" Ninja 26target. You can set Pigweed build options using ``gn args out`` or by running: 27 28.. code-block:: sh 29 30 gn gen out --args=' 31 pw_android_toolchain_NDK_PATH="/path/to/android/ndk"' 32 33On a Windows machine it's easier to run: 34 35.. code-block:: sh 36 37 gn args out 38 39That will open a text file where you can paste the args in: 40 41.. code-block:: text 42 43 pw_android_toolchain_NDK_PATH = "/path/to/android/ndk" 44 45Save the file and close the text editor. 46 47Then build with: 48 49.. code-block:: sh 50 51 ninja -C out android 52 53This will build Pigweed for all supported Android CPU targets at the default 54optimization level, currently arm, arm64, x64, and x86. 55 56To build for a specific CPU target only, at the default optimization level: 57 58.. code-block:: sh 59 60 ninja -C out arm64_android 61 62Or to build for a specific CPU target and optimization level: 63 64.. code-block:: sh 65 66 ninja -C out arm64_android_size_optimized 67