BT

New Tools from Google to Help Developing C/C++ Applications on Android

| by Sergio De Simone Follow 14 Followers on Dec 23, 2014. Estimated reading time: 2 minutes |

A new set of libraries and tools from Google's Fun Propulsion Labs, fplutil, promises to make it easier to develop C/C++ applications for Android.

Fplutil is made of four major parts: build_all_android.py, buildutil, libfplutil, and android_ndk_perf.py.

build_all_android.py

This build script allows to build, install, and run native apps from the command line. The script will build C/C++ apps on top of the Android NDK and is useful both for build automation and for streamlining the developer's compile/run loop.

The script supports specifying build settings from the command line, such as to set debug mode, optimization level, etc. It also supports the use of multiple devices at the same time.

buildutil

Buildutil is a set of Python modules that simplify the process of writing continuous automation scripts that use CMake. An example of using buildutil to build/archive an Android app is the following:

  1. First step is creating a android.BuildEnvironment instance to perform the rest of build operations:

    parser = argparse.ArgumentParser()
    buildutil.android.BuildEnvironment.add_arguments(parser)
    args = parser.parse_args()
    env = buildutil.android.BuildEnvironment(args)
    
  2. Once this step is done, the app is built using ndk-build for the native (C/C++) component and ant for the Java component and APK:

    (rc, errmsg) = env.build\_all()
    
  3. Finally, the APK can be archived to a zip file:

    env.make\_archive(['apks'], 'output.zip', exclude=['objs', 'objs-debug'])
    

Besides NDK builds on Android, this tool supports Linux, OS X, and Windows builds.

libfplutil

libfplutil consists of a native Android NDK module that builds two static libraries, libfplutil_main and libfplutil_print, that make it easier to write C/C++ applications:

  • libfplutil_main implements an Android NativeActivity entry point android_main() which calls the traditional C/C++ entry point int main(). This makes it possible to write an application with a int main() entry point (just like any standard C application), link against this library (see Linking) and have it run on Android.

  • libfplutil_print implements a set of wrappers for functions that write to the standard output stream. This enables applications that write to the terminal using printf to have their output redirected to the Android log.

By linking to libfplutil, the canonical Hello, World program can be compiled and run on Android without changes.

android_ndk_perf.py

This is a desktop tool that enables native (C/C++) developers to measure the CPU utilization of their applications on Android, guiding their optimization efforts. Android_ndk_perf can be run on developer's workstations to collect traces of applications running on Android devices. After application traces are collected the data can be examined using Linux Perf's commands or a HTML visualization can be generated for inspection in a web browser.

libfplutil can be downloaded from github, which also hosts its documentation.

Fun Propulsion Labs is a team within Google that's dedicated to advancing gaming on Android and other platforms. Early this year, they open-sourced LiquidFun 1.1, a 2D physics engine including fluid simulation.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT