Product
Solutions
Resources
Company
Download Trial Book a Demo
RKTracer · Android app code coverage

Code coverage for Android apps, Java and C/C++ (NDK)

RKTracer measures real Android app code coverage for your Java and C/C++ (JNI/NDK) sources, from statement and branch to MC/DC on the native side, on host, emulator or device, without changing your source or your Gradle build.

No source changes · host, emulator or device · HTML and XML reports

terminal · android coverage
# Turn RKTracer on, then rebuild your debug APK
$ ./gradlew assembleDebug
  instrumenting app/src (Java) + cpp (NDK)…
   instrumented APK built, no source modified

# Run on emulator or device, then report
$ ./gradlew connectedDebugAndroidTest
$ rkresults --report html
   statement 100% · branch 100% · native MC/DC 97.4%
Why Android coverage is hard

An Android app is two stacks in one APK

A modern Android app is not a single body of code. The application layer runs as Java on the Android runtime, while performance-sensitive and security-sensitive work drops into C and C++ through the NDK, called across the JNI boundary. Measuring Android app code coverage properly means measuring both stacks, on the device the app actually runs on, not just lines on a desktop build.

Most Android coverage tooling stops at line coverage on the managed layer and never sees the native side at all. The JNI and NDK code, often the most safety-relevant part of the app, goes unmeasured. And running coverage only on a host JVM tells you little about what executes on a real emulator or a physical device, where threading, lifecycle and hardware behave differently.

RKTracer treats the whole APK as one coverage surface. It instruments your Java sources and your C/C++ (JNI/NDK) sources together, captures coverage live on host, emulator or device, and reports it under one model. You prefix or enable, rebuild your debug APK, run the tests you already run, and get an evidence-grade report.

Java and native, one run

Coverage for the Java layer and the C/C++ (JNI/NDK) layer

One coverage model spanning the managed and native sides of your Android app, captured from a single instrumented execution.

Java application layer

Statement, branch, decision and function coverage on the Activities, services and view models that drive your app.

C/C++ via JNI and NDK

Full structural coverage on your native modules through the JNI boundary, up to MC/DC and multi-condition.

One report, both stacks

Java and native coverage land in the same HTML and XML report, so a coverage number means the same thing across the APK.

Step-by-step guides: Java in Android Studio · C/C++ in Android Studio · NDK application.

Host, emulator and real device

Measure coverage where the app really runs

RKTracer captures Android app code coverage on a host build, on an Android emulator, and on a physical device over ADB. By default it autosaves coverage data from the emulator or device back to the build machine, so you collect evidence from the environment that matches production.

  • Host build for fast unit-level feedback on JVM
  • Android emulator for instrumented and UI tests
  • Real device over ADB, the way the app ships
  • Autosave to the build machine, logcat fallback if disconnected
Coverage · payment_native.cppOn-device
Function100%
Statement100%
Branch100%
Condition100%
MC/DC97%
Multi-condition94%

Java
+ C/C++ (NDK)
ADB
device & emulator
rkresults
report output
Metrics through MC/DC

Every metric, up to MC/DC on the native side

From the basics on the Java layer to the hardest structural metric on your C and C++ code.

Function & Statement

Know which methods, functions and lines your suite reaches across Java and native code.

Branch & Decision

Confirm both outcomes of every if, switch and loop decision are exercised.

Condition & MC/DC

For C and C++, prove every condition independently affects its decision, the strongest structural metric.

Multi-Condition

On the native layer, cover every combination of conditions in compound Boolean expressions.

Coverage metricReferenced at
StatementDO-178C Level C · ISO 26262 ASIL A
Decision / BranchDO-178C Level B · ASIL B/C
MC/DC (C/C++)DO-178C Level A · ASIL D
Multi-Condition (C/C++)Deep verification · IEC 61508 SIL 4

RKValidate is an ISO 9001 quality-certified vendor. RKTracer measures the coverage metrics these standards reference; it does not itself carry a functional-safety certification. MC/DC and multi-condition apply to the C and C++ (NDK) layer.

Gradle, Android Studio and NDK

Set up Android coverage in an afternoon

No project restructure, no source edits. Enable instrumentation, then build the debug APK you already build.

1

Enable RKTracer

Turn instrumentation on from the Android Studio plugin (Tools menu) or with rktracer gradle -on app/build.gradle.

2

Rebuild the APK

Run ./gradlew assembleDebug. RKTracer instruments your Java and C/C++ (NDK) sources at the source level. Your code is never modified.

3

Run on emulator or device

Install over ADB and run unit, instrumented and UI tests. Coverage is captured live and autosaved to the build machine.

4

Generate the report

rkresults emits HTML and XML for review, CI and SonarQube. Merge reports across runs.

Selected files

Instrument exactly what your safety case covers

A simple config tells RKTracer which packages, modules and native folders to instrument, and which to leave alone. You can scope coverage down to individual functions on the native side.

  • instrument include Java packages and NDK folders
  • ignore skip generated, test and vendor code
  • never hard-exclude code that must not be touched
  • Per-function metric control on the C/C++ layer
rktracer.config
# Instrument only what matters for your safety case
instrument  app/src/main/java/com/acme/payments/**
instrument  app/src/main/cpp/crypto/*.cpp   # JNI/NDK

# Exclude generated, test and third-party code
ignore      app/src/androidTest/**
never       **/com/acme/legacy/**

# Per-function metric on the native layer
function    crypto_sign   metric=mcdc
CI and SonarQube

Gate every build on real Android coverage

Reports

  • HTML and XML output
  • Per-file Java and native coverage
  • Merge runs across emulator and device

CI servers

  • Jenkins publishing
  • Azure DevOps and GitLab CI
  • Fail the build below a coverage gate

SonarQube

  • Publishes coverage to SonarQube
  • Tracks coverage over time
  • One quality view for the whole APK
From coverage to tests

Coverage finds the gaps. Two ways to close them.

RKTracer pinpoints the uncovered lines, decisions and, on the native side, MC/DC conditions. Closing those gaps is a separate step, and you have two options.

RKTracer itself measures coverage; it does not generate tests. The two tools below do.

See the full RKTracer overview

RKMCP · AI-assisted

An MCP server that streams the uncovered code to your AI agent. The agent writes tests and the build, then runs and re-checks until the gaps close. It works across your stack.

RKTracerGen · offline, C/C++ only

A deterministic, fully offline unit-test generator for C and C++ only. For Android it applies to the native NDK code, not the Java layer. No AI, no tokens, no network.

FAQ

Android app code coverage, answered

Turn RKTracer instrumentation on, rebuild your debug APK with your existing Gradle build, install on an Android emulator or a real device, run your unit and instrumented tests, then generate the report. RKTracer instruments at the source level, so coverage maps to the Java and C/C++ (JNI/NDK) code your app actually ships.
RKTracer covers Java and C/C++ (JNI/NDK) sources in the same Android app, in one run. For the native C and C++ side it measures up to MC/DC and multi-condition coverage. There is one coverage model across the Java layer and the native layer.
Yes. RKTracer captures Android app code coverage on host builds, on Android emulators and on real devices over ADB. By default it autosaves coverage data from the emulator or device back to the build machine, and falls back to the logcat buffer if the device disconnects.
Yes, for the native C and C++ (JNI/NDK) code in your app. MC/DC and multi-condition are the strongest structural metrics, the ones the highest assurance levels reference. RKTracer measures them on the native layer alongside statement, branch, function and condition coverage.
No. You enable RKTracer instrumentation from the Android Studio plugin or with the rktracer gradle command, then rebuild your debug APK with the same Gradle build you already use. There are no source edits and no build-system rewrite.
RKTracer measures coverage and pinpoints the uncovered lines, decisions and MC/DC conditions. To close those gaps you can use RKMCP, which serves the gaps to your AI agent over MCP, or RKTracerGen, a deterministic offline unit-test generator for C and C++ only. For Android, RKTracerGen applies to the native NDK code, not to the Java layer.

Measure Android app code coverage on your own APK

Download the free 30-day trial and capture coverage on host, emulator or device this week, or book a 30-minute demo with an engineer.

Related: RKTracer overview · features · how it works · docs · contact