UPDATE: There seems to be a problem with std::atomic on Android, and since Boost.Asio is using it (by default), combined with threads, one occasionally got deadlocked. Fortunately Boost.Asio makes it easy to switch from Std.Atomic to Boost.Atomic and this has been taken care of in the Boost-for-Android project in this commit.
For more info about the bug, see here
We are developing a simple multiplayer game (not yet released) for Android using boost asio and so far we did not have any problems. That's for the question #2.
What kind of problems are you seeing?
If the problems are related to compiling and linking, perhaps these hints will prove useful.
Add following to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Have this in your Application.mk file:
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -fexceptions
And use this as a template for your Android.mk file:
LOCAL_PATH := $(call my-dir)
BOOST_VERSION := 1_49
PROJECT_ROOT := $(LOCAL_PATH)/../../../..
BOOST_INCLUDE_PATH := /path/to/boost/headers
BOOST_LIB_PATH := /path/to/boost/libraries
# Path and name of the STL library. Add this to the *end* of LOCAL_LDLIBS.
# Note this is a hack/workaround to prevent linker errors when compiling with
# boost.
STL_LIBS := -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
-lgnustl_static
include $(CLEAR_VARS)
LOCAL_MODULE := native-activity
LOCAL_C_INCLUDES:= $(BOOST_INCLUDE_PATH) \
$(PROJECT_ROOT)/src \
$(PROJECT_ROOT)/platform/android/jni
LOCAL_SRC_FILES := main.cpp
LOCAL_LDLIBS := -llog -landroid
# The order of these libraries is often important.
LOCAL_LDLIBS += -L$(BOOST_LIB_PATH) \
-lboost_system-gcc-mt-$(BOOST_VERSION) \
-lboost_thread-gcc-mt-$(BOOST_VERSION) \
$(STL_LIBS)
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
EDIT: How we build boost for Android. This is what we have in our Makefile:
git clone git://github.com/madadam/Boost-for-Android.git
./build-android.sh --boost=1.49.0 --with-libraries=chrono,program_options,system,thread /path/to/ndk
Note that we are using our own fork of Boost-for-Android, this is only because that one has a patch for the newest NDK version r8d. It can also be seen from the command line that we are using the 1.49 version of boost, this is currently the highest supported by Boost-for-Android.
If you would like to know what combinations of Boost and Android NDK are supported, have a look inside the Boost-for-Android project. It contains directories called patches/boost-<X>/ndk-android<Y> where X corresponds to the supported boost version and Y to the supported NDK version (shameless plug: our 2 cents to the project :-)).