-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to build 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://github.com/Microsoft/cpprestsdk.git casablanca
cd casablanca/Build_android
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.
- Hard link to version r10 for Linux: http://dl.google.com/android/ndk/android-ndk32-r10-linux-x86_64.tar.bz2
- Hard link to version r10 for Windows: http://dl.google.com/android/ndk/android-ndk32-r10-windows-x86_64.zip
For this tutorial, we assume it is installed at ~/android-ndk-r10/.
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.
See Use on Android.
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.
For reference, the older documentation is available at Setup and Build on Android 2.2.