Upgrade dependencies and build system

This commit switches to use official Google NDK version 16 with packages
created/installed using android-crew-staging tool derived from CrystaX
project.

Change-Id: I248fef2a871e44375512dcbf15a5f3166c0ab5de
diff --git a/app/build.gradle b/app/build.gradle
index 909fae0..d5eb0bf 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,14 +4,15 @@
 
 android {
     compileSdkVersion 26
-    buildToolsVersion "26.0.0"
+    buildToolsVersion "26.0.3"
 
     defaultConfig {
         applicationId "net.named_data.nfd"
-        minSdkVersion 15
-        targetSdkVersion 19
-        versionCode 4004
-        versionName "0.2.4 (NFD 0.5.0, ndn-cxx 0.5.0-11-g1cf4146e)"
+        minSdkVersion 23
+        targetSdkVersion 23
+        versionCode 4005
+        versionName "0.2.5 (NFD 0.5.0, ndn-cxx 0.5.0-11-g1cf4146e)"
+        multiDexEnabled true
     }
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_7
@@ -19,7 +20,7 @@
     }
     buildTypes {
         release {
-            minifyEnabled false
+            minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
         debug {
@@ -41,6 +42,9 @@
         exclude 'META-INF/LICENSE.txt'
         exclude 'META-INF/NOTICE.txt'
     }
+    lintOptions {
+      abortOnError false
+    }
 
     splits {
         abi {
@@ -51,11 +55,11 @@
 
     // map for the version code
     // versionCode digit for each supported ABI, with 64bit>32bit and x86>armeabi-*
-    project.ext.versionCodes = ['armeabi': 1,
+    project.ext.versionCodes = [//'armeabi': 1, // Deprecated in r16. Will be removed in r17. No hard float.
                                 'armeabi-v7a': 2,
                                 'arm64-v8a': 3,
-                                'mips': 5,
-                                'mips64': 6,
+                                // 'mips': 5,   // Deprecated in r16. Will be removed in r17. Uses hard-float, and assumes a CPU:FPU clock ratio of 2:1 for maximum compatibility. Provides neither micromips nor MIPS16.
+                                // 'mips64': 6, // Deprecated in r16. WIll be removed in r17
                                 'x86': 8,
                                 'x86_64': 9]
 
@@ -93,7 +97,7 @@
         }
 
         if (System.env.NDK_DEBUG != null) {
-           args.add("NDK_DEBUG=1")
+           args.add("V=1")
         }
         commandLine args
     }
@@ -142,18 +146,19 @@
 }
 
 dependencies {
-    compile fileTree(dir: 'libs', include: ['*.jar'])
-    compile 'com.android.support:appcompat-v7:23.1.1'
-    compile 'com.android.support:support-v4:23.1.1'
+    implementation fileTree(dir: 'libs', include: ['*.jar'])
+    implementation 'com.android.support:appcompat-v7:26.1.0'
+    implementation 'com.android.support:support-v4:26.1.0'
 
-    compile('com.intel.jndn.management:jndn-management:1.1.0') {
+    implementation('com.intel.jndn.management:jndn-management:1.1.3') {
       exclude group: 'net.named-data', module: 'jndn'
     }
-    compile('net.named-data:jndn-android:0.14') {
+    implementation('net.named-data:jndn-android:0.15') {
       exclude group: 'org.xerial'
+      exclude group: 'com.google.android'
     }
-    compile 'net.named-data.jndn-xx:jndn-xx-util:0.0.1'
-    compile 'joda-time:joda-time:2.7'
+    implementation 'net.named-data.jndn-xx:jndn-xx-util:0.0.1'
+    implementation 'joda-time:joda-time:2.9.9'
 }
 
 Properties properties = new Properties()
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 314d8a4..7b070a9 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -1,8 +1,115 @@
-# The simpliest strategy is to not run proguard against your project's own code.
-# This doesn't provide the benefits of optimization & obfuscation against your
-# project, but will still strip the libraries. The advantage is that your app will
-# work without any subsequent effort. If you choose this strategy, the proguard
-# configuration for the project is simply the line below.
+#-dontshrink
+#-dontoptimize
+#-dontpreverify
+-verbose
+-dontwarn javax.annotation.**
+-dontwarn com.google.**
+-dontwarn org.joda.convert.**
 
-# -keep class net.named_data.nfd.** { * ; }
-# -keep class net.named_data.jndn.** { * ; }
+-dontnote org.sqlite.JDBC
+-dontnote javax.xml.bind.DatatypeConverter
+-dontnote com.google.appengine.api.ThreadManager
+-dontnote com.google.apphosting.api.ApiProxy
+
+#
+
+-renamesourcefileattribute SourceFile
+
+-keepattributes SourceFile,LineNumberTable
+
+# RemoteViews might need annotations.
+
+-keepattributes *Annotation*
+
+# Preserve all fundamental application classes.
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+
+# Preserve all View implementations, their special context constructors, and
+# their setters.
+
+-keep public class * extends android.view.View {
+    public <init>(android.content.Context);
+    public <init>(android.content.Context, android.util.AttributeSet);
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+    public void set*(...);
+}
+
+# Preserve all classes that have special context constructors, and the
+# constructors themselves.
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+# Preserve all classes that have special context constructors, and the
+# constructors themselves.
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+# Preserve the special fields of all Parcelable implementations.
+
+-keepclassmembers class * implements android.os.Parcelable {
+    static android.os.Parcelable$Creator CREATOR;
+}
+
+# Preserve static fields of inner classes of R classes that might be accessed
+# through introspection.
+
+-keepclassmembers class **.R$* {
+  public static <fields>;
+}
+
+# Preserve the required interface from the License Verification Library
+# (but don't nag the developer if the library is not used at all).
+
+-keep public interface com.android.vending.licensing.ILicensingService
+
+-dontnote com.android.vending.licensing.ILicensingService
+
+# The Android Compatibility library references some classes that may not be
+# present in all versions of the API, but we know that's ok.
+
+-dontwarn android.support.**
+
+# Preserve all native method names and the names of their classes.
+
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+# Preserve the special static methods that are required in all enumeration
+# classes.
+
+-keepclassmembers class * extends java.lang.Enum {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+# Explicitly preserve all serialization members. The Serializable interface
+# is only a marker interface, so it wouldn't save them.
+# You can comment this out if your application doesn't use serialization.
+# If your code contains serializable classes that have to be backward
+# compatible, please refer to the manual.
+
+-keepclassmembers class * implements java.io.Serializable {
+    static final long serialVersionUID;
+    static final java.io.ObjectStreamField[] serialPersistentFields;
+    private void writeObject(java.io.ObjectOutputStream);
+    private void readObject(java.io.ObjectInputStream);
+    java.lang.Object writeReplace();
+    java.lang.Object readResolve();
+}
+
+# Your application may contain more items that need to be preserved;
+# typically classes that are dynamically created using Class.forName:
+
+# -keep public class mypackage.MyClass
+# -keep public interface mypackage.MyInterface
+# -keep public class * implements mypackage.MyInterface
diff --git a/app/src/main/java/net/named_data/nfd/DrawerFragment.java b/app/src/main/java/net/named_data/nfd/DrawerFragment.java
index bf8e29d..60144a0 100644
--- a/app/src/main/java/net/named_data/nfd/DrawerFragment.java
+++ b/app/src/main/java/net/named_data/nfd/DrawerFragment.java
@@ -1,6 +1,6 @@
 /* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2015 Regents of the University of California
+ * Copyright (c) 2015-2017 Regents of the University of California
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
  * See AUTHORS.md for complete list of NFD Android authors and contributors.
@@ -33,8 +33,8 @@
 import android.support.v4.widget.DrawerLayout;
 import android.support.v4.widget.ViewDragHelper;
 import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
 import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.app.AppCompatActivity;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -334,7 +334,7 @@
    * @return Host activity's ActionBar.
    */
   private ActionBar getActionBar() {
-    return ((ActionBarActivity)getActivity()).getSupportActionBar();
+    return ((AppCompatActivity)getActivity()).getSupportActionBar();
   }
 
   //////////////////////////////////////////////////////////////////////////////
diff --git a/app/src/main/java/net/named_data/nfd/MainActivity.java b/app/src/main/java/net/named_data/nfd/MainActivity.java
index ee19928..c3a13ba 100644
--- a/app/src/main/java/net/named_data/nfd/MainActivity.java
+++ b/app/src/main/java/net/named_data/nfd/MainActivity.java
@@ -24,7 +24,7 @@
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
 import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.AppCompatActivity;
 import android.view.Menu;
 import android.view.MenuItem;
 
@@ -39,7 +39,7 @@
 /**
  * Main activity that is loaded for the NFD app.
  */
-public class MainActivity extends ActionBarActivity
+public class MainActivity extends AppCompatActivity
     implements DrawerFragment.DrawerCallbacks,
                LogcatFragment.Callbacks,
                FaceListFragment.Callbacks,
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 3ab102d..1b2d4e4 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
@@ -1,6 +1,6 @@
 /* -*- Mode:jde; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2015 Regents of the University of California
+ * Copyright (c) 2015-2017 Regents of the University of California
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon) Android.
  * See AUTHORS.md for complete list of NFD Android authors and contributors.
@@ -54,30 +54,29 @@
   static {
     // At least on Galaxy S3 (4.1.1), all shared library dependencies that are located
     // in app's lib folder (not in /system/lib) need to be explicitly loaded.
-    // The script https://gist.github.com/cawka/11fe9c23b7a13960330b can be used to
-    // calculate proper dependency load list.
+    // Use `ndk-depends` to automatically generate this list.
     // For example:
     //     cd app/src/main/libs/armeabi-v7a/
     //     bash android-shared-lib-dependencies.sh nfd-wrapper
-    System.loadLibrary("crystax");
-    System.loadLibrary("gnustl_shared");
-    System.loadLibrary("cryptopp_shared");
-    System.loadLibrary("boost_system");
-    System.loadLibrary("boost_filesystem");
-    System.loadLibrary("boost_date_time");
-    System.loadLibrary("boost_iostreams");
-    System.loadLibrary("boost_program_options");
-    System.loadLibrary("boost_chrono");
-    System.loadLibrary("boost_random");
-    System.loadLibrary("ndn-cxx");
-    System.loadLibrary("boost_thread");
-    System.loadLibrary("nfd-daemon");
+    // System.loadLibrary("crystax");
+    // System.loadLibrary("gnustl_shared");
+    // System.loadLibrary("cryptopp_shared");
+    // System.loadLibrary("boost_system");
+    // System.loadLibrary("boost_filesystem");
+    // System.loadLibrary("boost_date_time");
+    // System.loadLibrary("boost_iostreams");
+    // System.loadLibrary("boost_program_options");
+    // System.loadLibrary("boost_chrono");
+    // System.loadLibrary("boost_random");
+    // System.loadLibrary("ndn-cxx");
+    // System.loadLibrary("boost_thread");
+    // System.loadLibrary("nfd-daemon");
     System.loadLibrary("nfd-wrapper");
   }
 
   /**
    * Native API for starting the NFD.
-   *
+   * <p/>
    * @param params NFD parameters.  Must include 'homePath' with absolute path of the home directory
    *               for the service (ContextWrapper.getFilesDir().getAbsolutePath())
    */
diff --git a/app/src/main/jni/Android.mk b/app/src/main/jni/Android.mk
index 4ab6a50..20989c2 100644
--- a/app/src/main/jni/Android.mk
+++ b/app/src/main/jni/Android.mk
@@ -10,5 +10,3 @@
 
 include $(LOCAL_PATH_SAVED)/ndn-cxx.mk
 include $(LOCAL_PATH_SAVED)/nfd.mk
-
-$(call import-module,boost/1.59.0)
diff --git a/app/src/main/jni/Application.mk b/app/src/main/jni/Application.mk
index 976b943..793e7c4 100644
--- a/app/src/main/jni/Application.mk
+++ b/app/src/main/jni/Application.mk
@@ -1,7 +1,8 @@
-APP_ABI := all
+APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
 
 APP_STL := gnustl_shared
-APP_CPPFLAGS += -fexceptions -frtti -std=c++11 -Wno-deprecated-declarations
+APP_CPPFLAGS += -fexceptions -frtti -std=c++11
+# -Wno-deprecated-declarations
 
-NDK_TOOLCHAIN_VERSION := 5
-APP_PLATFORM := android-19
+NDK_TOOLCHAIN_VERSION := 4.9
+APP_PLATFORM := android-23
diff --git a/app/src/main/jni/ndn-cxx b/app/src/main/jni/ndn-cxx
index 1cf4146..17c83c2 160000
--- a/app/src/main/jni/ndn-cxx
+++ b/app/src/main/jni/ndn-cxx
@@ -1 +1 @@
-Subproject commit 1cf4146eb9d5ea5604072e096bf11e2dffa136eb
+Subproject commit 17c83c2467dd468dfa8684cc9f5412dc1b7c59dd
diff --git a/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp b/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp
index f669a93..d7d1858 100644
--- a/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp
+++ b/app/src/main/jni/ndn-cxx-android/ndn-cxx-config.hpp
@@ -1,7 +1,7 @@
 #ifndef W_SRC_NDN_CXX_CONFIG_HPP_WAF
 #define W_SRC_NDN_CXX_CONFIG_HPP_WAF
 
-#define NDN_CXX_HAVE_STD_TO_STRING 1
+// #define NDN_CXX_HAVE_STD_TO_STRING 1
 #define NDN_CXX_HAVE_VECTOR_INSERT_ERASE_CONST_ITERATOR 1
 #define NDN_CXX_HAVE_IS_DEFAULT_CONSTRUCTIBLE 1
 #define NDN_CXX_HAVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE 1
diff --git a/app/src/main/jni/ndn-cxx.mk b/app/src/main/jni/ndn-cxx.mk
index d467bac..b47ea5c 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_shared opencrypto_shared openssl_shared $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
+LOCAL_SHARED_LIBRARIES := cryptopp_shared libcrypto_shared libssl_shared $(addsuffix _shared,$(addprefix boost_,$(NDN_CXX_BOOST_LIBS)))
 LOCAL_STATIC_LIBRARIES := sqlite3_static boost_regex_static
 NDN_CXX_SRC_FILES := \
     data.cpp \
@@ -145,6 +145,6 @@
 
 include $(LOCAL_PATH_SAVED)/cryptopp/extras/jni/Android.mk
 
-$(call import-module,boost/1.59.0)
-$(call import-module,sqlite/3)
-$(call import-module,openssl/1.0.2h)
+$(call import-module,../packages/boost/1.65.1)
+$(call import-module,../packages/sqlite/3.18.0)
+$(call import-module,../packages/openssl/1.0.2m)
diff --git a/app/src/main/jni/nfd.mk b/app/src/main/jni/nfd.mk
index c8e6818..77c27b8 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_shared openssl_shared ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
+LOCAL_SHARED_LIBRARIES := cryptopp_shared libcrypto_shared libssl_shared ndn-cxx $(addsuffix _shared,$(addprefix boost_,$(NFD_BOOST_LIBS)))
 NFD_DAEMON_SRC_FILES := \
     core/city-hash.cpp \
     core/config-file.cpp \