Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 1 | NFD on Android |
| 2 | ============== |
| 3 | |
Alexander Afanasyev | 808ce31 | 2016-01-23 18:11:59 -0800 | [diff] [blame] | 4 | [](https://travis-ci.org/named-data-mobile/NFD-android) |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 5 | |
| 6 | ## Prerequisites |
| 7 | |
| 8 | To compile code, the following is necessary |
| 9 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 10 | - Recent version of [Android SDK](http://developer.android.com/sdk/index.html) |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 11 | |
Alexander Afanasyev | 652fb8e | 2017-07-07 10:46:09 -0700 | [diff] [blame] | 12 | Example script for Ubuntu 16.04 to get all dependencies, download SDK and NDK: |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 13 | |
Alexander Afanasyev | 652fb8e | 2017-07-07 10:46:09 -0700 | [diff] [blame] | 14 | sudo apt -q update |
| 15 | sudo apt -qy upgrade |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 16 | sudo apt-get install -y build-essential git openjdk-8-jdk unzip ruby ruby-rugged |
Alexander Afanasyev | a409156 | 2016-02-23 11:51:31 -0800 | [diff] [blame] | 17 | sudo apt-get install -y lib32stdc++6 lib32z1 lib32z1-dev |
Alexander Afanasyev | f381256 | 2016-01-21 16:28:33 -0800 | [diff] [blame] | 18 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 19 | 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 Afanasyev | f381256 | 2016-01-21 16:28:33 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 25 | export ANDROID_HOME=`pwd` |
| 26 | export PATH=${PATH}:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 28 | echo "y" | sdkmanager "platform-tools" |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 29 | sdkmanager "platforms;android-28" "ndk-bundle" |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 30 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 31 | cd ndk-bundle |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 32 | git clone https://github.com/named-data-mobile/android-crew-staging crew.dir |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 33 | |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 34 | 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 Afanasyev | a8d404b | 2016-11-05 10:07:08 -0600 | [diff] [blame] | 36 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 37 | cd .. |
Alexander Afanasyev | a8d404b | 2016-11-05 10:07:08 -0600 | [diff] [blame] | 38 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 39 | The above `crew` scripts will install pre-compiled versions of sqlite, openssl, and boost libraries. |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 40 | For more details about the crew tool, refer to README-dev.md. |
Alexander Afanasyev | a8d404b | 2016-11-05 10:07:08 -0600 | [diff] [blame] | 41 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 42 | ## Building |
| 43 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 44 | git clone --recursive http://gerrit.named-data.net/NFD-android |
| 45 | echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 46 | echo ndk.dir=`pwd`/android-sdk-linux/ndk-bundle >> NFD-android/local.properties |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 47 | cd NFD-android |
| 48 | |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 49 | # Build in release mode (you will need to have proper signing keys configured, see README-dev.md) |
Alexander Afanasyev | 7395caf | 2016-01-31 10:33:28 -0800 | [diff] [blame] | 50 | ./gradlew assembleRelease |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 51 | |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 52 | # Build in debug mode |
| 53 | ./gradlew assembleDebug |
| 54 | |
| 55 | You 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 Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 62 | |
Alexander Afanasyev | da06629 | 2017-11-12 23:02:31 -0500 | [diff] [blame] | 63 | Note 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 | |
| 67 | will limit build to `armeabi-v7a` and `x86_64`. |
| 68 | |
| 69 | By default, the build script will try to parallelize build to the number of CPUs. This can be |
| 70 | overridden using `NDK_BUILD_PARALLEL` variable. |
| 71 | |
Alexander Afanasyev | 14fd3e2 | 2018-07-04 14:20:53 -0400 | [diff] [blame^] | 72 | To upload `.apk` files to Google Play (need configuration of keys and Google Play credentials, see README-dev.md): |
| 73 | |
| 74 | ./gradlew publishRelease |
| 75 | |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 76 | ## Setting up environment using Vagrant |
| 77 | |
| 78 | The development setup can be set up with [Vagrant](https://www.vagrantup.com/) and scripts provided |
| 79 | in `.vagrant/` folder. After vagrant command-line is installed, the following will create VM |
| 80 | environment and fetch all necessary dependencies: |
| 81 | |
| 82 | cd .vagrant |
| 83 | vagrant up |
Alexander Afanasyev | 81e7d87 | 2015-04-19 19:38:26 -0700 | [diff] [blame] | 84 | vagrant ssh |
Alexander Afanasyev | 087c7c1 | 2015-02-02 00:21:21 -0800 | [diff] [blame] | 85 | |
| 86 | Refer to vagrant documentation for more information. |