blob: 2ccb0a76b6c02034412582a3f5b1e9d44a19cdbf [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 Afanasyevda066292017-11-12 23:02:31 -050010- Recent version of [Android SDK](http://developer.android.com/sdk/index.html)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080011
Alexander Afanasyev652fb8e2017-07-07 10:46:09 -070012Example script for Ubuntu 16.04 to get all dependencies, download SDK and NDK:
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080013
Alexander Afanasyev652fb8e2017-07-07 10:46:09 -070014 sudo apt -q update
15 sudo apt -qy upgrade
Alexander Afanasyevda066292017-11-12 23:02:31 -050016 sudo apt-get install -y build-essential git openjdk-8-jdk unzip ruby ruby-rugged
Alexander Afanasyeva4091562016-02-23 11:51:31 -080017 sudo apt-get install -y lib32stdc++6 lib32z1 lib32z1-dev
Alexander Afanasyevf3812562016-01-21 16:28:33 -080018
Alexander Afanasyevda066292017-11-12 23:02:31 -050019 mkdir android-sdk-linux
20 cd android-sdk-linux
21 wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
22 unzip sdk-tools-linux-3859397.zip
23 rm sdk-tools-linux-3859397.zip
Alexander Afanasyevf3812562016-01-21 16:28:33 -080024
Alexander Afanasyevda066292017-11-12 23:02:31 -050025 export ANDROID_HOME=`pwd`
26 export PATH=${PATH}:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080027
Alexander Afanasyevda066292017-11-12 23:02:31 -050028 echo "y" | sdkmanager "platform-tools"
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040029 sdkmanager "platforms;android-28" "ndk-bundle"
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080030
Alexander Afanasyevda066292017-11-12 23:02:31 -050031 cd ndk-bundle
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040032 git clone https://github.com/named-data-mobile/android-crew-staging crew.dir
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080033
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040034 CREW_OWNER=named-data-mobile crew.dir/crew install target/sqlite target/openssl target/boost
35 CREW_OWNER=named-data-mobile crew.dir/crew install target/ndn_cxx target/nfd
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060036
Alexander Afanasyevda066292017-11-12 23:02:31 -050037 cd ..
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060038
Alexander Afanasyevda066292017-11-12 23:02:31 -050039The above `crew` scripts will install pre-compiled versions of sqlite, openssl, and boost libraries.
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040040For more details about the crew tool, refer to README-dev.md.
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060041
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080042## Building
43
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080044 git clone --recursive http://gerrit.named-data.net/NFD-android
45 echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties
Alexander Afanasyevda066292017-11-12 23:02:31 -050046 echo ndk.dir=`pwd`/android-sdk-linux/ndk-bundle >> NFD-android/local.properties
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080047 cd NFD-android
48
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040049 # Build in release mode (you will need to have proper signing keys configured, see README-dev.md)
Alexander Afanasyev7395caf2016-01-31 10:33:28 -080050 ./gradlew assembleRelease
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080051
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040052 # Build in debug mode
53 ./gradlew assembleDebug
54
55You can also automatically install debug/release NDN-android to the connected phone
56
57 # build and install release version (will require signing key configuration)
58 ./gradlew installRelease
59
60 # build and install debug version
61 ./gradlew installDebug
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080062
Alexander Afanasyevda066292017-11-12 23:02:31 -050063Note that you can limit architectures being built using `NDK_BUILD_ABI` variable. For example,
64
65 export NDK_BUILD_ABI=armeabi-v7a,x86_64
66
67will limit build to `armeabi-v7a` and `x86_64`.
68
69By default, the build script will try to parallelize build to the number of CPUs. This can be
70overridden using `NDK_BUILD_PARALLEL` variable.
71
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040072To upload `.apk` files to Google Play (need configuration of keys and Google Play credentials, see README-dev.md):
73
74 ./gradlew publishRelease
75
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080076## Setting up environment using Vagrant
77
78The development setup can be set up with [Vagrant](https://www.vagrantup.com/) and scripts provided
79in `.vagrant/` folder. After vagrant command-line is installed, the following will create VM
80environment and fetch all necessary dependencies:
81
82 cd .vagrant
83 vagrant up
Alexander Afanasyev81e7d872015-04-19 19:38:26 -070084 vagrant ssh
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080085
86Refer to vagrant documentation for more information.