How to build and setup for Android on Linux (2.3+)

Note: if you are on Windows, we now have a NuGet package! Go straight to Use on Android to get started.

First, follow all the instructions on Setup and Build on Linux. While some steps could be skipped if you only want to build for Android, it is useful to diagnose problems with a desktop build first.

Second, while our dependencies require a Linux system to build, once they are built you can transfer the products to a Windows computer and use them with your existing Android project under Eclipse. More information on this is provided in the relevant step. The C++ REST SDK depends on Boost, libiconv, and OpenSSL when used on Android. The script below will compile all of these dependencies for you.

For this walkthrough, we assume you are working within the Build_Android directory of the C++ REST SDK.

git clone https://git01.codeplex.com/casablanca
cd casablanca/Build_android

Install the Android NDK

The following instructions are written and tested against the android NDK version r10. Future and past versions may or may not work. The android NDK is available at http://developer.android.com/tools/sdk/ndk/index.html. If version r10 is not available for download, hard links are provided below.

For this tutorial, we assume it is installed at ~/android-ndk-r10/.

Building the C++ REST SDK

mkdir build
cd build
../configure.sh --ndk ~/android-ndk-r10

This will build armv7 binaries under the build.armv7.debug/Binaries and build.armv7.release/Binaries folders.

Using the C++ REST SDK

See Use on Android.

Running Tests

If you want to run the tests for Android we have a test runner project that can used. All the tests can be built by running msbuild from the command line. For example the following setups up the Visual Studio tools and builds x86 Debug for the simulator.

.\setup_ps_env_VS2015.ps1
cd Release
msbuild /p:Platform=x86 /p:Configuration=Debug

Once the build completes open the following androidproj file in Visual Studio, which packages the tests.

Release\tests\common\TestRunner\vs14.android\TestRunner.android.Packaging\TestRunner.android.Packaging.androidproj

Make sure the configuration is x86 Debug and then start debugging with F5. This will launch the Android emulator and start running the tests. Output of the tests goes to Logcat, which can be brought up the Visual Studio menu with Tools->Android Tools->Logcat. Look for messages with the tag 'UnitTestpp', in particular at the end of running the tests there are several '--- Flush buffer ---' messages in a row.

Old versions

For reference, the older documentation is available at Setup and Build on Android 2.2.

Last edited Dec 23, 2014 at 9:32 PM by stevetgates, version 13