diff --git a/contrib/src/ffmpeg/rules.mak b/contrib/src/ffmpeg/rules.mak
index 3ff65c545a496b056ffe8c45274cf98e2df95227..0dd4cfa653ba9e02f4d42b6d3de4fd6810951b8b 100644
--- a/contrib/src/ffmpeg/rules.mak
+++ b/contrib/src/ffmpeg/rules.mak
@@ -37,9 +37,7 @@ FFMPEGCONF += \
 
 #librairies
 ifndef HAVE_ANDROID
-FFMPEGCONF += \
-		--enable-libx264 \
-		--enable-libvpx
+FFMPEGCONF += --enable-libx264
 endif
 
 #encoders/decoders
@@ -66,6 +64,7 @@ FFMPEGCONF += \
 		--enable-decoder=mjpegb \
 		--enable-libspeex \
 		--enable-libopus \
+		--enable-libvpx \
 		--enable-encoder=libspeex \
 		--enable-decoder=libspeex \
 		--enable-encoder=libopus \
diff --git a/contrib/src/pjproject/isblank.patch b/contrib/src/pjproject/isblank.patch
new file mode 100644
index 0000000000000000000000000000000000000000..98f6f1e827e695ce6d1608fd274d2fed8aa77325
--- /dev/null
+++ b/contrib/src/pjproject/isblank.patch
@@ -0,0 +1,8 @@
+--- pjproject/pjlib/include/pj/compat/ctype.h	2016-10-06 16:39:29.708512865 -0400
++++ pjproject/pjlib/include/pj/compat/ctype.h	2016-10-06 17:39:00.084513427 -0400
+@@ -43,5 +43,2 @@
+ 
+-#ifndef isblank
+-#   define isblank(c)	    (c==' ' || c=='\t')
+-#endif
+ 
diff --git a/contrib/src/pjproject/rules.mak b/contrib/src/pjproject/rules.mak
index f7ac9ede4cff34854989db6e56a978e1056e413b..da0e0fb4a0f39cbab9c15e8cbece657895ec7290 100644
--- a/contrib/src/pjproject/rules.mak
+++ b/contrib/src/pjproject/rules.mak
@@ -69,6 +69,7 @@ endif
 	$(APPLY) $(SRC)/pjproject/notestsapps.patch
 ifdef HAVE_ANDROID
 	$(APPLY) $(SRC)/pjproject/android.patch
+	$(APPLY) $(SRC)/pjproject/isblank.patch
 endif
 	$(APPLY) $(SRC)/pjproject/ipv6.patch
 	$(APPLY) $(SRC)/pjproject/ice_config.patch
diff --git a/contrib/src/vpx/rules.mak b/contrib/src/vpx/rules.mak
index 3aa647abea62a88975426ad480b6cfb330711c6a..acfd37586da8f698d290e1b2eb1c9f66fa3aec30 100644
--- a/contrib/src/vpx/rules.mak
+++ b/contrib/src/vpx/rules.mak
@@ -117,7 +117,7 @@ ifdef HAVE_ANDROID
 # uses that path to look for the compiler (which we already know)
 VPX_CONF += --sdk-path=$(ANDROID_TOOLCHAIN)/bin
 # needed for cpu-features.h
-VPX_CONF += --extra-cflags="-I$(ANDROID_NDK)/sources/cpufeatures/"
+VPX_CONF += --extra-cflags="-I$(ANDROID_NDK)/sources/cpufeatures/ -fvisibility=hidden"
 # set an explicit alternative libc since the sysroot override can make it blank
 VPX_CONF += --libc=$(SYSROOT)
 LOCAL_HOSTVARS=$(HOSTVARS)
diff --git a/src/ip_utils.h b/src/ip_utils.h
index 63a1cfc50ad083e029c9a3b3105c87151ff89341..e704839f0f8828fa298e2a19f4d9edd5c1ce31fe 100644
--- a/src/ip_utils.h
+++ b/src/ip_utils.h
@@ -21,7 +21,9 @@
 #ifndef IP_UTILS_H_
 #define IP_UTILS_H_
 
+extern "C" {
 #include <pjlib.h>
+}
 
 #ifdef HAVE_CONFIG
  #include <config.h>
diff --git a/src/string_utils.h b/src/string_utils.h
index 707c88f33a196e856ee152a30bfeafc91c01b399..d2b8c813a558dd653451f3ada11866d6aee477f1 100644
--- a/src/string_utils.h
+++ b/src/string_utils.h
@@ -25,10 +25,6 @@
 #include <string>
 #include <vector>
 
-#ifdef __ANDROID__
-#include <sstream>
-#endif
-
 namespace ring {
 
 constexpr static const char* TRUE_STR = "true";
@@ -48,42 +44,6 @@ std::wstring to_wstring(const std::string& s);
 
 #endif
 
-#ifdef __ANDROID__
-
-// Rationale:
-// Some strings functions are not available on Android NDK as explained here:
-// http://stackoverflow.com/questions/17950814/how-to-use-stdstoul-and-stdstoull-in-android/18124627#18124627
-// We implement them by ourself as well as possible here.
-
-template <typename T>
-inline std::string
-to_string(T &&value)
-{
-    std::ostringstream os;
-    os << value;
-    return os.str();
-}
-
-static inline int
-stoi(const std::string& str)
-{
-    int v;
-    std::istringstream os(str);
-    os >> v;
-    return v;
-}
-
-static inline double
-stod(const std::string& str)
-{
-    double v;
-    std::istringstream os(str);
-    os >> v;
-    return v;
-}
-
-#else
-
 template <typename T>
 inline std::string
 to_string(T &&value)
@@ -103,8 +63,6 @@ stod(const std::string& str)
     return std::stod(str);
 }
 
-#endif
-
 std::string trim(const std::string &s);
 
 std::vector<std::string>
diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp
index 4b55061311c69b56255236cc1279035e3fdf95c4..6ccadaa34ab2bcaaf02bebb7d5aab60dedadb90a 100644
--- a/src/upnp/upnp_context.cpp
+++ b/src/upnp/upnp_context.cpp
@@ -24,15 +24,6 @@
 
 #include "upnp_context.h"
 
-#include <string>
-#include <set>
-#include <mutex>
-#include <memory>
-#include <condition_variable>
-#include <random>
-#include <chrono>
-#include <cstdlib> // for std::free
-
 #if HAVE_LIBUPNP
 #include <upnp/upnp.h>
 #include <upnp/upnptools.h>
@@ -50,6 +41,15 @@
 #include <opendht/rng.h>
 using random_device = dht::crypto::random_device;
 
+#include <string>
+#include <set>
+#include <mutex>
+#include <memory>
+#include <condition_variable>
+#include <random>
+#include <chrono>
+#include <cstdlib> // for std::free
+
 namespace ring { namespace upnp {
 
 /**
diff --git a/src/upnp/upnp_context.h b/src/upnp/upnp_context.h
index a2aa196add30d10613ef862c1edeae6df756979e..c5d8c41dbc57e2753cf3047c66fe74a4d1a7d4fd 100644
--- a/src/upnp/upnp_context.h
+++ b/src/upnp/upnp_context.h
@@ -24,15 +24,6 @@
 #include "config.h"
 #endif
 
-#include <set>
-#include <map>
-#include <mutex>
-#include <memory>
-#include <condition_variable>
-#include <chrono>
-#include <atomic>
-#include <thread>
-
 #if HAVE_LIBUPNP
 #ifdef _WIN32
 #define UPNP_STATIC_LIB
@@ -50,6 +41,15 @@
 #include "noncopyable.h"
 #include "upnp_igd.h"
 
+#include <set>
+#include <map>
+#include <mutex>
+#include <memory>
+#include <condition_variable>
+#include <chrono>
+#include <atomic>
+#include <thread>
+
 namespace ring {
 class IpAddr;
 }