On the Android platform, code coverage is available using Ant+Emma. However, that only covers Java code, so if your app is composed of native code as well, you'll want another tool. Fortunately, Gcov is one such tool, and is reasonably easy to setup.
First, compile your native code with gcov support:
I got timestamp mismatch errors when targeting multiple ABI's, so I also recommend only selecting one ABI in Application.mk.
(Optional) I'm not sure about Ant, but in Eclipse, you can define multiple native build configurations, which makes it much easier to switch back and forth between your coverage build and debug/release build. Simply add an argument to the build command, and branch on that argument in your Android.mk file.
Designate the gcov output directory. This requires setting two environment variables. These variables need to be set from a native library that's loaded before your main library. We'll define a very small library composed of one source file.
The output path is passed in from Java, so you can change it without having to recompile your native code.
Make sure you then load the coverage library:
Due to the way Android terminates processes, you'll need to flush the coverage data manually at some point. This can be accomplished with a call to
Run the app and you should start getting coverage data. The data will be in the form of .gcda files, which will appear in the
Once you have coverage data, the next step is to generate a coverage report.