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
# 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%
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.
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.
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
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 metric | Referenced at |
|---|---|
| Statement | DO-178C Level C · ISO 26262 ASIL A |
| Decision / Branch | DO-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.
Set up Android coverage in an afternoon
No project restructure, no source edits. Enable instrumentation, then build the debug APK you already build.
Enable RKTracer
Turn instrumentation on from the Android Studio plugin (Tools menu) or with rktracer gradle -on app/build.gradle.
Rebuild the APK
Run ./gradlew assembleDebug. RKTracer instruments your Java and C/C++ (NDK) sources at the source level. Your code is never modified.
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.
Generate the report
rkresults emits HTML and XML for review, CI and SonarQube. Merge reports across runs.
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
# 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
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
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 overviewRKMCP · 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.
Android app code coverage, answered
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.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