MathFu
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups Pages
Building for Android

Version Requirements

Following are the minimum tested versions of the tools and libraries you need to build MathFu for Android:

Prerequisites

Prior to building:

Building

Each MathFu project for Android has an associated AndroidManifest.xml file and jni subdirectory. Unit tests and benchmarks directories contain projects that each build an Android package (apk) which can be installed and executed on Android devices.

The following directories in the MathFu project contain Android NDK projects:

  • mathfu/
    • Rules used to build the MathFu library.
  • mathfu/benchmarks
    • Each subdirectory under this directory contains a simple benchmark used to measure the performance of different build configurations.
  • mathfu/unit_tests
    • Each subdirectory under this directory contains a unit test application used to test different components of the library in different build configurations.

Building with ndk-build

To build a single Android NDK project (without packaging the native component in an apk):

  • Open a command line window.
  • Go to the directory containing the project to build.
  • ndk-build

For example, to build the matrix test for the default build configuration without generating an apk:

cd mathfu/unit_tests/matrix_test/default
ndk-build

Building with fplutil

To build all Android NDK projects, install and run them on a device:

  • Open a command line window.
  • Go to the MathFu project directory.
  • Execute dependencies/fplutil/bin/build_all_android.py

For example:

cd mathfu
./dependencies/fplutil/bin/build_all_android.py

Installing and Running Applications

Using Eclipse

Running a sample requires the Android Developer Tools (ADT) plugin and the NDK Eclipse plugin.

  • Build a project using ndk-build (see above).
  • Open ADT Eclipse.
  • Select "File->Import..." from the menu.
  • Select "Android > Existing Android Code Into Workspace", and click "Next".
  • Click the "Browse..." button next to Root Directory: and select the project folder (e.g. mathfu/unit_tests/matrix_test/default).
  • Click "Finish". Eclipse imports the project, and displays it in the Package Explorer pane.
  • Right-click the project, and select "Run->Run As->Android Application" from the menu.
  • If you do not have a physical device, you must define a virtual one. For details about how to define a virtual device, see managing avds. We don’t recommend a virtual device for development.
  • None of the applications have a visual component so their output is visible via the log (adb logcat).

Using fplutil

To install and run a single application:

  • Open a command line window.
  • Go to the directory containing the project to install and run.
  • Execute dependencies/fplutil/bin/build_all_android.py with the -i and -r options.

For example:

cd mathfu/unit_tests/matrix_test/default
./dependencies/fplutil/bin/build_all_android.py -i -r

To install and run all applications:

  • Open a command line window.
  • Go to the MathFu project directory.
  • Execute dependencies/fplutil/bin/build_all_android.py with the -i and -r options.

For example:

cd mathfu
./dependencies/fplutil/bin/build_all_android.py -i -r

Code Generation

By default, code is generated for devices that support the armeabi-v7a ABI. Alternatively, you can generate a fat .apk that includes code for all ABIs. To do so, override APP_ABI on ndk-build's command line.

Using ndk-build:

ndk-build APP_ABI=all

Using fplutil:

./dependencies/fplutil/bin/build_all_android.py -f APP_ABI=all