blob: 7f69ca913084be617c285c85554230b64349673a [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 Afanasyevb49dd9c2020-05-28 23:02:09 -040010- Recent version of [Android command line tools](http://developer.android.com/sdk/index.html)
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080011
Alexander Afanasyevb49dd9c2020-05-28 23:02:09 -040012Example script for Ubuntu 18.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 Afanasyevb49dd9c2020-05-28 23:02:09 -040019 mkdir android
20 cd android
21 mkdir -p cmdline-tools
22 mv tools cmdline-tools/latest
23 wget https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip
24 unzip commandlinetools-linux-6514223_latest.zip
25 rm commandlinetools-linux-6514223_latest.zip
Alexander Afanasyevf3812562016-01-21 16:28:33 -080026
Alexander Afanasyevda066292017-11-12 23:02:31 -050027 export ANDROID_HOME=`pwd`
Alexander Afanasyevb49dd9c2020-05-28 23:02:09 -040028 export PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080029
Alexander Afanasyevda066292017-11-12 23:02:31 -050030 echo "y" | sdkmanager "platform-tools"
Alexander Afanasyevb49dd9c2020-05-28 23:02:09 -040031 sdkmanager "platforms;android-29" "ndk-bundle"
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080032
Alexander Afanasyevda066292017-11-12 23:02:31 -050033 cd ndk-bundle
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040034 git clone https://github.com/named-data-mobile/android-crew-staging crew.dir
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080035
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040036 CREW_OWNER=named-data-mobile crew.dir/crew install target/sqlite target/openssl target/boost
37 CREW_OWNER=named-data-mobile crew.dir/crew install target/ndn_cxx target/nfd
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060038
Alexander Afanasyevda066292017-11-12 23:02:31 -050039 cd ..
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060040
Alexander Afanasyevda066292017-11-12 23:02:31 -050041The above `crew` scripts will install pre-compiled versions of sqlite, openssl, and boost libraries.
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040042For more details about the crew tool, refer to README-dev.md.
Alexander Afanasyeva8d404b2016-11-05 10:07:08 -060043
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080044## Building
45
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080046 git clone --recursive http://gerrit.named-data.net/NFD-android
47 echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties
Alexander Afanasyevda066292017-11-12 23:02:31 -050048 echo ndk.dir=`pwd`/android-sdk-linux/ndk-bundle >> NFD-android/local.properties
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080049 cd NFD-android
50
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040051 # Build in release mode (you will need to have proper signing keys configured, see README-dev.md)
Alexander Afanasyev7395caf2016-01-31 10:33:28 -080052 ./gradlew assembleRelease
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080053
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040054 # Build in debug mode
55 ./gradlew assembleDebug
56
57You can also automatically install debug/release NDN-android to the connected phone
58
59 # build and install release version (will require signing key configuration)
60 ./gradlew installRelease
61
62 # build and install debug version
63 ./gradlew installDebug
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080064
Alexander Afanasyevda066292017-11-12 23:02:31 -050065Note that you can limit architectures being built using `NDK_BUILD_ABI` variable. For example,
66
67 export NDK_BUILD_ABI=armeabi-v7a,x86_64
68
69will limit build to `armeabi-v7a` and `x86_64`.
70
71By default, the build script will try to parallelize build to the number of CPUs. This can be
72overridden using `NDK_BUILD_PARALLEL` variable.
73
Alexander Afanasyev14fd3e22018-07-04 14:20:53 -040074To upload `.apk` files to Google Play (need configuration of keys and Google Play credentials, see README-dev.md):
75
76 ./gradlew publishRelease
77
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080078## Setting up environment using Vagrant
79
80The development setup can be set up with [Vagrant](https://www.vagrantup.com/) and scripts provided
81in `.vagrant/` folder. After vagrant command-line is installed, the following will create VM
82environment and fetch all necessary dependencies:
83
84 cd .vagrant
85 vagrant up
Alexander Afanasyev81e7d872015-04-19 19:38:26 -070086 vagrant ssh
Alexander Afanasyev087c7c12015-02-02 00:21:21 -080087
88Refer to vagrant documentation for more information.