ndk+ci: Upgrade to use CrystaX NDK 10.3.1 and a more recent version of Crypto++ library

This commit also fixes checks with Travis-CI that were effectively broken before.

Change-Id: Ibf9e54de47db00ed01534187a19a3d40e9dee84e
diff --git a/.gitmodules b/.gitmodules
index 63dd1fa..d011c56 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,6 @@
 [submodule "app/src/main/jni/cryptopp"]
     path = app/src/main/jni/cryptopp
-    url = https://github.com/cawka/cryptopp
+    url = https://github.com/named-data-mobile/cryptopp
     branch = android
 [submodule "app/src/main/jni/ndn-cxx"]
     path = app/src/main/jni/ndn-cxx
diff --git a/.jenkins.d/10-get-ndk.sh b/.jenkins.d/10-get-ndk.sh
index 07f1942..4b66ca6 100755
--- a/.jenkins.d/10-get-ndk.sh
+++ b/.jenkins.d/10-get-ndk.sh
@@ -2,10 +2,12 @@
 set -e
 set -x
 
-URL=https://www.crystax.net/download/
-NDK=crystax-ndk-10.2.1
+CRYSTAX_NDK_VERSION=10.3.1
 
-NDK_FILE="$NDK-linux-x86_64.tar.bz2"
+URL=https://www.crystax.net/download/
+NDK=crystax-ndk-$CRYSTAX_NDK_VERSION
+
+NDK_FILE="$NDK-linux-x86_64.tar.xz"
 
 if [ ! -f downloads/$NDK_FILE ]; then
     mkdir downloads || true
@@ -15,8 +17,28 @@
 fi
 
 if [ ! -d $NDK ]; then
+    export XZ_DEFAULTS=--memlimit=300MiB
     echo -en 'travis_fold:start:NDK\r'
-    pv -f downloads/$NDK_FILE | tar xjf -
+
+    # To save space
+    EXCLUDES="toolchains/*-clang3.6 toolchains/*-3.6 \
+            toolchains/*-clang3.7 \
+            toolchains/*-3.7 \
+            toolchains/*-4.9 \
+            sources/cxx-stl/gabi++ \
+            sources/cxx-stl/llvm-libc++ \
+            sources/cxx-stl/llvm-libc++abi \
+            sources/cxx-stl/stlport \
+            sources/cxx-stl/llvm-libc++ \
+            sources/cxx-stl/gnu-libstdc++/4.9 \
+            sources/icu \
+            sources/boost/*/libs/*/gnu-4.9 \
+            sources/boost/*/libs/*/llvm-3.6 \
+            sources/boost/*/libs/*/llvm-3.7 \
+            sources/objc \
+            sources/python"
+
+    pv -f downloads/$NDK_FILE | tar xJf - $(for i in $EXCLUDES; do echo "--exclude $i"; done | xargs)
     echo -en 'travis_fold:end:NDK\r'
 fi
 
diff --git a/.jenkins.d/10-get-sdk.sh b/.jenkins.d/10-get-sdk.sh
old mode 100644
new mode 100755
index 4b801dd..fef1aaa
--- a/.jenkins.d/10-get-sdk.sh
+++ b/.jenkins.d/10-get-sdk.sh
@@ -2,25 +2,31 @@
 set -e
 set -x
 
-SDK_TOOLS_VERSION=24.0.2
+GRADLE_VERSION=2.10
+SDK_VERSION=24.4.1
 BUILD_TOOLS_VERSION=21.1.2
 COMPILE_SDK_VERSION=21
 
-export ANDROID_HOME=`pwd`/android-sdk-linux
-export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
-export PATH=$PATH:`pwd`/gradle-2.9/bin
+SDK=android-sdk-linux
 
-if [ ! -d android-sdk-linux ]; then
-    wget -q http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz
-    tar zxf android-sdk_r24.0.2-linux.tgz
-    rm android-sdk_r24.0.2-linux.tgz
+export ANDROID_HOME=`pwd`/$SDK
+export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
+
+if [ ! -d $SDK ]; then
+    wget -nv http://dl.google.com/android/android-sdk_r$SDK_VERSION-linux.tgz
+    tar zxf android-sdk_r$SDK_VERSION-linux.tgz
+    rm android-sdk_r$SDK_VERSION-linux.tgz
 
     echo "y" | android update sdk --filter platform-tools,build-tools-$BUILD_TOOLS_VERSION,android-$COMPILE_SDK_VERSION,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --all --force
     echo "y" | android update sdk --filter "android-19" --no-ui --all --force
 fi
 
-wget -q https://services.gradle.org/distributions/gradle-2.9-bin.zip
-unzip gradle-2.9-bin.zip
-rm gradle-2.9-bin.zip
+if [ ! -d gradle-$GRADLE_VERSION ]; then
+    wget -nv https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip
+    unzip gradle-$GRADLE_VERSION-bin.zip
+    rm gradle-$GRADLE_VERSION-bin.zip
 
-echo sdk.dir=`pwd`/android-sdk-linux >> local.properties
+    ln -s `pwd`/gradle-$GRADLE_VERSION/bin/gradle gradle
+fi
+
+echo sdk.dir=`pwd`/$SDK >> local.properties
diff --git a/.travis.yml b/.travis.yml
index f36664f..cee130e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,18 +1,5 @@
-language: android
-android:
-  components:
-    - platform-tools
-    - build-tools-21.1.2
-    - android-19
-    - android-21
-    - extra-android-support
-    - extra-android-m2repository
-    - extra-google-m2repository
-    # - tools
-    # - extra
-    # - extra-google-google_play_services
-    # - addon-google_apis-google-19
-    # - sys-img-armeabi-v7a-android-19
+sudo: false
+language: generic
 jdk:
   - openjdk7
 notifications:
@@ -26,9 +13,27 @@
  - NDK_BUILD_ABI=mips
  - NDK_BUILD_ABI=x86
  - NDK_BUILD_ABI=x86_64
+addons:
+  apt:
+    packages:
+     - lib32stdc++6
+     - lib32z1
+     - lib32z1-dev
+     - build-essential
+     - wget
+     - unzip
 before_install:
-  - travis_retry sudo apt-get update -qq
-  - travis_retry sudo apt-get install -y build-essential unzip wget pv
+  - wget https://www.ivarch.com/programs/sources/pv-1.6.0.tar.bz2
+  - tar xjf pv-1.6.0.tar.bz2
+  - cd pv-1.6.0
+  - ./configure --prefix=$HOME --disable-nls
+  - make install
+  - cd ..
+  - rm pv-1.6.0.tar.bz2
+  - export PATH=$HOME/bin:$PATH
+  - travis_retry .jenkins.d/10-get-sdk.sh
   - travis_retry .jenkins.d/10-get-ndk.sh
 script:
-  - GRADLE_OPTS="-Xmx768m -Xms256m -Xss1m" NDK_BUILD_PARALLEL=1 gradle assembleRelease
+  - git submodule update --init --recursive
+  - ./gradle --version
+  - GRADLE_OPTS="-Xmx768m -Xms256m -Xss1m" NDK_BUILD_PARALLEL=1 ./gradle assembleDebug --console plain
diff --git a/.vagrant/Vagrantfile b/.vagrant/Vagrantfile
index 2d7b315..4f6ba1c 100644
--- a/.vagrant/Vagrantfile
+++ b/.vagrant/Vagrantfile
@@ -4,23 +4,27 @@
 VAGRANTFILE_API_VERSION = "2"
 
 $script = <<SCRIPT
+
+CRYSTAX_NDK_VERSION=10.3.1
+
+GRADLE_VERSION=2.10
+SDK_VERSION=24.4.1
+BUILD_TOOLS_VERSION=21.1.2
+COMPILE_SDK_VERSION=21
+
 sudo apt-get install -y build-essential git openjdk-7-jdk unzip
 
 # SDK binaries need i386 libraries
 sudo dpkg --add-architecture i386;
 sudo apt-get update -qq; sudo apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386
 
-wget -q https://www.crystax.net/download/crystax-ndk-10.2.1-linux-x86_64.tar.bz2
-tar jxf crystax-ndk-10.2.1-linux-x86_64.tar.bz2
-rm crystax-ndk-10.2.1-linux-x86_64.tar.bz2
+wget -nv https://www.crystax.net/download/crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
+tar xf crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
+rm crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
 
-wget -q http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz
-tar zxf android-sdk_r24.0.2-linux.tgz
-rm android-sdk_r24.0.2-linux.tgz
-
-SDK_TOOLS_VERSION=24.0.2
-BUILD_TOOLS_VERSION=21.1.2
-COMPILE_SDK_VERSION=21
+wget -nv http://dl.google.com/android/android-sdk_r$SDK_VERSION-linux.tgz
+tar zxf android-sdk_r$SDK_VERSION-linux.tgz
+rm android-sdk_r$SDK_VERSION-linux.tgz
 
 export ANDROID_HOME=`pwd`/android-sdk-linux
 export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
@@ -28,13 +32,13 @@
 echo "y" | android update sdk --filter platform-tools,build-tools-$BUILD_TOOLS_VERSION,android-$COMPILE_SDK_VERSION,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --all --force
 echo "y" | android update sdk --filter "android-19" --no-ui --all --force
 
-wget -q https://services.gradle.org/distributions/gradle-2.9-bin.zip
-unzip gradle-2.9.bin.zip
-rm gradle-2.9-bin.zip
-export PATH=$PATH:`pwd`/gradle-2.9/bin
+wget -nv https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip
+unzip gradle-$GRADLE_VERSION-bin.zip
+rm gradle-$GRADLE_VERSION-bin.zip
+export PATH=$PATH:`pwd`/gradle-$GRADLE_VERSION/bin
 
 echo sdk.dir=`pwd`/android-sdk-linux > local.properties
-echo ndk.dir=`pwd`/crystax-ndk-10.2.1 >> local.properties
+echo ndk.dir=`pwd`/crystax-ndk-$CRYSTAX_NDK_VERSION >> local.properties
 SCRIPT
 
 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -43,10 +47,7 @@
   config.vm.provision "shell", privileged: false, inline: $script
 
   config.vm.provider "virtualbox" do |vb|
-    # Don't boot with headless mode
-    vb.gui = false
-
-    # Use VBoxManage to customize the VM. For example to change memory:
-    vb.customize ["modifyvm", :id, "--memory", "4048", "--cpus", "4"]
+    vb.memory = 4048
+    vb.cpus = 4
   end
 end
diff --git a/README.md b/README.md
index a0f1816..dbd75fc 100644
--- a/README.md
+++ b/README.md
@@ -7,46 +7,55 @@
 
 To compile code, the following is necessary
 
-- Appropriate [Android SDK](http://developer.android.com/sdk/index.html)
-- [CrystalX Android NDK](https://www.crystax.net/en/download) version 10.2.1 or later
+- Recent version of [Android SDK](http://developer.android.com/sdk/index.html), android-21 SDK
+  and 21.1.2 build tools (for build), android-19 SDK (for compatibility), and several other SDK
+  components
+- [CrystalX Android NDK](https://www.crystax.net/en/download) version 10.3.1
+- [Gradle build automation system](http://gradle.org/) version 2.10
 
 Example script for Ubuntu 14.04 to get all dependencies, download SDK and NDK:
 
-    sudo apt-get install -y build-essential git openjdk-7-jdk unzip
-    wget -q https://www.crystax.net/download/crystax-ndk-10.2.1-linux-x86_64.tar.bz2
-    tar jxf crystax-ndk-10.2.1-linux-x86_64.tar.bz2
+    CRYSTAX_NDK_VERSION=10.3.1
+    GRADLE_VERSION=2.10
+    SDK_VERSION=24.4.1
 
-    wget -q http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz
-    tar zxf android-sdk_r24.0.2-linux.tgz
-    rm android-sdk_r24.0.2-linux.tgz
-
-    echo y |  ./android-sdk-linux/tools/android update sdk -a -u -t "android-19"
-
-    wget -q https://services.gradle.org/distributions/gradle-2.9-bin.zip
-    unzip gradle-2.9-bin.zip
-
-    SDK_TOOLS_VERSION=24.0.2
     BUILD_TOOLS_VERSION=21.1.2
     COMPILE_SDK_VERSION=21
 
-    (sudo dpkg --add-architecture i386; sudo apt-get update -qq; sudo apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386)
+    sudo apt-get install -y build-essential git openjdk-7-jdk unzip
+
+    # SDK binaries need i386 libraries
+    sudo dpkg --add-architecture i386;
+    sudo apt-get update -qq; sudo apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386
+
+    wget https://www.crystax.net/download/crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
+    tar xf crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
+    rm crystax-ndk-$CRYSTAX_NDK_VERSION-linux-x86_64.tar.xz
+
+    wget http://dl.google.com/android/android-sdk_r$SDK_VERSION-linux.tgz
+    tar zxf android-sdk_r$SDK_VERSION-linux.tgz
+    rm android-sdk_r$SDK_VERSION-linux.tgz
 
     export ANDROID_HOME=`pwd`/android-sdk-linux
     export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
 
-    echo "y" | ~/android-sdk-linux/tools/android update sdk --filter platform-tools,build-tools-$BUILD_TOOLS_VERSION,android-$COMPILE_SDK_VERSION,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --all --force
+    echo "y" | android update sdk --filter platform-tools,build-tools-$BUILD_TOOLS_VERSION,android-$COMPILE_SDK_VERSION,extra-android-support,extra-android-m2repository,extra-google-m2repository --no-ui --all --force
+    echo "y" | android update sdk --filter "android-19" --no-ui --all --force
 
-    echo "y" | ~/android-sdk-linux/tools/android update sdk --filter "android-19" --no-ui --all --force
+    wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip
+    unzip gradle-$GRADLE_VERSION-bin.zip
+    rm gradle-$GRADLE_VERSION-bin.zip
+    export PATH=$PATH:`pwd`/gradle-$GRADLE_VERSION/bin
 
 ## Building
 
 
     git clone --recursive http://gerrit.named-data.net/NFD-android
     echo sdk.dir=`pwd`/android-sdk-linux > NFD-android/local.properties
-    echo ndk.dir=`pwd`/crystax-ndk-10.2.1 >> NFD-android/local.properties
+    echo ndk.dir=`pwd`/crystax-ndk-10.3.1 >> NFD-android/local.properties
     cd NFD-android
 
-    ../gradle/gradle-2.9/bin/gradle assembleRelease
+    ../gradle/gradle-2.10/bin/gradle assembleRelease
 
 
 ## Setting up environment using Vagrant
diff --git a/app/src/main/java/net/named_data/nfd/service/NfdService.java b/app/src/main/java/net/named_data/nfd/service/NfdService.java
index 1b43df3..74adec3 100644
--- a/app/src/main/java/net/named_data/nfd/service/NfdService.java
+++ b/app/src/main/java/net/named_data/nfd/service/NfdService.java
@@ -57,7 +57,7 @@
     //     bash android-shared-lib-dependencies.sh nfd-wrapper
     System.loadLibrary("crystax");
     System.loadLibrary("gnustl_shared");
-    System.loadLibrary("cryptopp");
+    System.loadLibrary("cryptopp_shared");
     System.loadLibrary("boost_system");
     System.loadLibrary("boost_filesystem");
     System.loadLibrary("boost_date_time");
diff --git a/app/src/main/jni/Android.mk b/app/src/main/jni/Android.mk
index 3eed95a..4ab6a50 100644
--- a/app/src/main/jni/Android.mk
+++ b/app/src/main/jni/Android.mk
@@ -11,4 +11,4 @@
 include $(LOCAL_PATH_SAVED)/ndn-cxx.mk
 include $(LOCAL_PATH_SAVED)/nfd.mk
 
-$(call import-module,boost/1.57.0)
+$(call import-module,boost/1.59.0)
diff --git a/app/src/main/jni/Application.mk b/app/src/main/jni/Application.mk
index 121e000..976b943 100644
--- a/app/src/main/jni/Application.mk
+++ b/app/src/main/jni/Application.mk
@@ -1,5 +1,7 @@
 APP_ABI := all
 
 APP_STL := gnustl_shared
-APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti
+APP_CPPFLAGS += -fexceptions -frtti -std=c++11 -Wno-deprecated-declarations
 
+NDK_TOOLCHAIN_VERSION := 5
+APP_PLATFORM := android-19
diff --git a/app/src/main/jni/cryptopp b/app/src/main/jni/cryptopp
index dfa7453..3a081d5 160000
--- a/app/src/main/jni/cryptopp
+++ b/app/src/main/jni/cryptopp
@@ -1 +1 @@
-Subproject commit dfa7453a47f397bad10a662a4117ffed99638513
+Subproject commit 3a081d5e25ad1c54f27a104f8e0f01c7e2ff4145
diff --git a/app/src/main/jni/ndn-cxx.mk b/app/src/main/jni/ndn-cxx.mk
index fc758f6..9ebba73 100644
--- a/app/src/main/jni/ndn-cxx.mk
+++ b/app/src/main/jni/ndn-cxx.mk
@@ -4,7 +4,7 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := ndn-cxx
 NDN_CXX_BOOST_LIBS = system filesystem date_time iostreams program_options chrono random
-LOCAL_SHARED_LIBRARIES := cryptopp $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
+LOCAL_SHARED_LIBRARIES := cryptopp_shared $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
 LOCAL_STATIC_LIBRARIES := sqlite3_static boost_regex_static
 NDN_CXX_SRC_FILES := \
     data.cpp \
@@ -114,7 +114,7 @@
 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ndn-cxx-android
 include $(BUILD_SHARED_LIBRARY)
 
-include $(LOCAL_PATH_SAVED)/cryptopp/Android.mk
+include $(LOCAL_PATH_SAVED)/cryptopp/extras/jni/Android.mk
 
-$(call import-module,boost/1.57.0)
+$(call import-module,boost/1.59.0)
 $(call import-module,sqlite/3)
diff --git a/app/src/main/jni/nfd.mk b/app/src/main/jni/nfd.mk
index 76e3cc8..c185955 100644
--- a/app/src/main/jni/nfd.mk
+++ b/app/src/main/jni/nfd.mk
@@ -6,7 +6,7 @@
 # nfd itself
 include $(CLEAR_VARS)
 LOCAL_MODULE := nfd-daemon
-LOCAL_SHARED_LIBRARIES := cryptopp ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
+LOCAL_SHARED_LIBRARIES := cryptopp_shared ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
 NFD_DAEMON_SRC_FILES := \
     core/city-hash.cpp \
     core/config-file.cpp \
diff --git a/build.gradle b/build.gradle
index e725ddd..32c901f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,7 +8,7 @@
         }
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
+        classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
         classpath 'net.named-data.playground:play-publisher:1.2.0-2-SNAPSHOT'
 
         // NOTE: Do not place your application dependencies here; they belong