blob: d3aabf7cd4c1a64295fca0d0b1e44f0e2b170c0f [file] [log] [blame] [view]
Alexander Afanasyev087c7c12015-02-02 00:21:21 -08001NFD on Android
2==============
3
Alexander Afanasyev808ce312016-01-23 18:11:59 -08004[![Build Status](https://travis-ci.org/named-data-mobile/NFD-android.svg?branch=master)](https://travis-ci.org/named-data-mobile/NFD-android)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -08005
6## Prerequisites
7
8To compile code, the following is necessary
9
Alexander Afanasyeva4091562016-02-23 11:51:31 -080010- Recent version of [Android SDK](http://developer.android.com/sdk/index.html), android-23 SDK
11 and 23.0.2 build tools (for build), android-19 SDK (for compatibility), and several other SDK
Alexander Afanasyevf3812562016-01-21 16:28:33 -080012 components
13- [CrystalX Android NDK](https://www.crystax.net/en/download) version 10.3.1
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060014- Prebuilt version of OpenSSL library
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080015
16Example script for Ubuntu 14.04 to get all dependencies, download SDK and NDK:
17
Alexander Afanasyevf3812562016-01-21 16:28:33 -080018 CRYSTAX_NDK_VERSION=10.3.1
Alexander Afanasyevf3812562016-01-21 16:28:33 -080019 SDK_VERSION=24.4.1
Lei Pi381cb282017-02-10 22:13:47 -060020 OPENSSL_VERSION=1.0.2h
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080021
Alexander Afanasyeva4091562016-02-23 11:51:31 -080022 BUILD_TOOLS_VERSION=23.0.2
23 COMPILE_SDK_VERSION=23
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080024
Alexander Afanasyevf3812562016-01-21 16:28:33 -080025 sudo apt-get install -y build-essential git openjdk-7-jdk unzip
Alexander Afanasyeva4091562016-02-23 11:51:31 -080026 sudo apt-get install -y lib32stdc++6 lib32z1 lib32z1-dev
Alexander Afanasyevf3812562016-01-21 16:28:33 -080027
28 wget https://www.crystax.net/download/crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
29 tar xf crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
30 rm crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
31
32 wget http://dl.google.com/android/android-sdk_r$SDK_VERSION-linux.tgz
33 tar zxf android-sdk_r$SDK_VERSION-linux.tgz
34 rm android-sdk_r$SDK_VERSION-linux.tgz
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080035
36 export ANDROID_HOME=`pwd`/android-sdk-linux
37 export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
38
Haitao Zhanga2a340f2017-03-19 16:45:55 -070039 echo "y" | android update sdk --filter platform-tools,build-tools-$BUILD_TOOLS_VERSION,android-$COMPILE_SDK_VERSION,extra-android-m2repository,extra-google-m2repository --no-ui --all --force
Alexander Afanasyevf3812562016-01-21 16:28:33 -080040 echo "y" | android update sdk --filter "android-19" --no-ui --all --force
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080041
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060042To create prebuilt OpenSSL libraries:
43
44 git clone https://github.com/crystax/android-vendor-openssl.git
45 cd crystax-ndk-$CRYSTAX_NDK_VERSION
46 ./build/tools/build-target-openssl.sh ../android-vendor-openssl/
Lei Pi381cb282017-02-10 22:13:47 -060047 cp sources/openssl/1.0.1p/Android.mk -o sources/openssl/$OPENSSL_VERSION/Android.mk
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060048
49Alternatively, you can use precompiled versions (currently, available for CrystaX NDK 10.3.1 only):
50
51 cd crystax-ndk-10.3.1/sources
52 curl -L -o openssl.tar.gz https://github.com/named-data-mobile/crystax-prebuilt-openssl/archive/crystax-10.3.1.tar.gz
53 tar zx --strip-components 1 -C openssl -f openssl.tar.gz
54 rm openssl.tar.gz
55
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080056## Building
57
58
59 git clone --recursive http://gerrit.named-data.net/NFD-android
60 echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties
Alexander Afanasyevf3812562016-01-21 16:28:33 -080061 echo ndk.dir=`pwd`/crystax-ndk-10.3.1 >> NFD-android/local.properties
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080062 cd NFD-android
63
Alexander Afanasyev7395caf2016-01-31 10:33:28 -080064 ./gradlew assembleRelease
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080065
66
67## Setting up environment using Vagrant
68
69The development setup can be set up with [Vagrant](https://www.vagrantup.com/) and scripts provided
70in `.vagrant/` folder. After vagrant command-line is installed, the following will create VM
71environment and fetch all necessary dependencies:
72
73 cd .vagrant
74 vagrant up
Alexander Afanasyev81e7d872015-04-19 19:38:26 -070075 vagrant ssh
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080076
77Refer to vagrant documentation for more information.