blob: 5bf920eb69487f8b75369ae17c8ae70a22d75ad7 [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
Alexander Afanasyev652fb8e2017-07-07 10:46:09 -070016Example script for Ubuntu 16.04 to get all dependencies, download SDK and NDK:
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080017
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 Afanasyev652fb8e2017-07-07 10:46:09 -070025 sudo apt -q update
26 sudo apt -qy upgrade
27 sudo apt-get install -y build-essential git openjdk-8-jdk unzip
Alexander Afanasyeva4091562016-02-23 11:51:31 -080028 sudo apt-get install -y lib32stdc++6 lib32z1 lib32z1-dev
Alexander Afanasyevf3812562016-01-21 16:28:33 -080029
30 wget https://www.crystax.net/download/crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
31 tar xf crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
32 rm crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
33
34 wget http://dl.google.com/android/android-sdk_r$SDK_VERSION-linux.tgz
35 tar zxf android-sdk_r$SDK_VERSION-linux.tgz
36 rm android-sdk_r$SDK_VERSION-linux.tgz
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080037
38 export ANDROID_HOME=`pwd`/android-sdk-linux
39 export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
40
Haitao Zhanga2a340f2017-03-19 16:45:55 -070041 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 -080042 echo "y" | android update sdk --filter "android-19" --no-ui --all --force
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080043
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060044To create prebuilt OpenSSL libraries:
45
46 git clone https://github.com/crystax/android-vendor-openssl.git
47 cd crystax-ndk-$CRYSTAX_NDK_VERSION
48 ./build/tools/build-target-openssl.sh ../android-vendor-openssl/
Lei Pi381cb282017-02-10 22:13:47 -060049 cp sources/openssl/1.0.1p/Android.mk -o sources/openssl/$OPENSSL_VERSION/Android.mk
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060050
51Alternatively, you can use precompiled versions (currently, available for CrystaX NDK 10.3.1 only):
52
53 cd crystax-ndk-10.3.1/sources
54 curl -L -o openssl.tar.gz https://github.com/named-data-mobile/crystax-prebuilt-openssl/archive/crystax-10.3.1.tar.gz
55 tar zx --strip-components 1 -C openssl -f openssl.tar.gz
56 rm openssl.tar.gz
57
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080058## Building
59
60
61 git clone --recursive http://gerrit.named-data.net/NFD-android
62 echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties
Alexander Afanasyevf3812562016-01-21 16:28:33 -080063 echo ndk.dir=`pwd`/crystax-ndk-10.3.1 >> NFD-android/local.properties
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080064 cd NFD-android
65
Alexander Afanasyev7395caf2016-01-31 10:33:28 -080066 ./gradlew assembleRelease
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080067
68
69## Setting up environment using Vagrant
70
71The development setup can be set up with [Vagrant](https://www.vagrantup.com/) and scripts provided
72in `.vagrant/` folder. After vagrant command-line is installed, the following will create VM
73environment and fetch all necessary dependencies:
74
75 cd .vagrant
76 vagrant up
Alexander Afanasyev81e7d872015-04-19 19:38:26 -070077 vagrant ssh
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080078
79Refer to vagrant documentation for more information.