Auditing an Android App Before Release: The Bugs Normal Use Never Shows / Dec 1, 2026
Brainbolt is a timed mental arithmetic trainer for Android that I'm working on for a client, Orange Draft. It has twelve operation families, six answer modes and thirty levels each, with every question generated on the device so it works offline and with no account. It isn't released yet.
I didn't write it from scratch. The client bought the codebase as a template, and my job was to take it apart before it reached the Play Store. That turned out to be harder than starting from nothing, for one reason: the app ran, looked complete and never crashed. The defects that survive to release are the ones normal use doesn't reveal. Nothing pointed at them. They only showed up when the code was read against what it claimed to do.
These are the findings, and the habits that found them.
A score nobody could ever get
The product document promised a top score of 500 for the fastest answers. In practice, 400 was the real maximum. Nobody had ever scored 500, and nobody could.
The score bands were absolute times written for a 30 second clock. The timer had since been set to 25 seconds. On top of that, an Android countdown's first tick reports slightly less than the full duration. So the condition for the fastest band never evaluated true, not once.
The numbers in this sketch are illustrative, but the shape of the bug is the real one:
// Before: absolute bands, written when a round lasted 30 seconds.
static int pointsBefore(long msLeft) {
if (msLeft >= 25_000) return 500; // a 25 s round never has 25 s left
if (msLeft >= 20_000) return 400;
if (msLeft >= 10_000) return 300;
return 100;
}
// After: bands as fractions of the round, so retuning the timer can't break them.
static int points(long msLeft, long roundMs) {
double left = (double) msLeft / roundMs;
if (left >= 0.80) return 500;
if (left >= 0.60) return 400;
if (left >= 0.30) return 300;
return 100;
}With the first tick of a 25 second round at 24,980 ms, the old version returns 400 and the new one returns 500. It still returns 500 on a 30 second round.
The habit: for every score, level or threshold, ask "what is the highest value this can actually produce?" and compare it with what the product promises.
A quiz you could pass without doing maths
Multiple choice offered the correct answer and three wrong ones. The wrong ones were always the answer plus ten, minus ten and plus twenty. Shuffled, that looks random. It isn't. Sort the four and the correct answer is always the second smallest. And whenever "minus ten" would have been negative, it was the smallest instead.
A player didn't need to do any arithmetic, only to notice the pattern. That undermines the whole point of a maths trainer.
The fix was wrong answers from both directions, scaled to the size of the answer, with a random split above and below:
static List<Integer> options(int answer, Random rng) {
int spread = Math.max(3, Math.abs(answer) / 5);
int below = rng.nextInt(4); // how many wrong answers sit below the answer: 0 to 3
Set<Integer> wrong = new LinkedHashSet<>();
while (wrong.size() < 3) {
boolean down = wrong.size() < below;
int step = 1 + rng.nextInt(spread);
int candidate = down ? answer - step : answer + step;
if (candidate >= 0 && candidate != answer) wrong.add(candidate);
else if (down) below = Math.max(0, below - 1); // no room below zero: go up instead
}
List<Integer> options = new ArrayList<>(wrong);
options.add(answer);
Collections.shuffle(options, rng);
return options;
}The real version goes further and shapes wrong answers to look like genuine slips rather than random numbers. The important part is the check that proves the pattern is gone. With the sketch above, generate 100,000 questions and count where the correct answer lands once the options are sorted:
| Smallest | 2nd | 3rd | Largest | |
|---|---|---|---|---|
| Fixed offsets | 0 | 100,000 | 0 | 0 |
| Both directions, random split | 25,031 | 25,058 | 24,948 | 24,963 |
The habit: you can't see a bias one question at a time. Generate in bulk and count.
A lives counter with no height
The game gives you lives, shown as hearts. Except players never saw them. Each heart was set as a background image on a view with no size of its own, so the view measured zero pixels high. The first time a player learned how many lives they had was a dialog telling them they had none left.
The same loop that drew the hearts existed in four separate places. They were replaced with one implementation drawn at an explicit size.
The habit: when the same code appears four times, a bug in it appears four times too. Duplication is where "fixed it" quietly means "fixed one of them".
No warning that time was running out
Four modes are timed. Only one of them changed colour as the clock ran down. The other three ran the same 25 seconds with no signal at all. A warning was added to all three.
This isn't a crash or a security issue. It's the kind of gap that makes an app feel unfair, and a review that only looks for errors walks straight past it.
Fifteen screens any app could open
Of the app's sixteen activities, fifteen were exported with no intent filter and no permission. Any app installed on the same phone could start them directly. That includes the results screen, which reads the state of a round that, if you jump straight to it, doesn't exist yet.
The fix is one attribute per activity:
<!-- src/main/AndroidManifest.xml -->
<activity
android:name=".ResultsActivity"
android:exported="false" />(ResultsActivity is an illustrative name.) The project's verification tooling needed to launch
some screens directly, so they were re-exported for debug builds only, with a manifest in the
debug source set that overrides the attribute:
<!-- src/debug/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity
android:name=".ResultsActivity"
android:exported="true"
tools:replace="android:exported" />
</application>
</manifest>Release builds never see that file, so the store version stays closed.
The bug that hasn't happened yet
One finding was documented rather than fixed, because it hasn't bitten anyone yet. The app's database version has never changed, and there is no upgrade path. So the first time a future release changes the schema, it will either fail outright or, using the library's only shortcut, wipe the database and every player's progress.
That isn't a missing feature. It's data loss waiting for the next release, and writing it down now means whoever makes that change knows to write a migration first.
The template's identity, and the ads
A bought template also carries its previous owner around:
- The app id and the privacy policy URL pointed at the template's author.
- Ad settings weren't separated by build type. They now are, so a development phone can't register a real ad impression and a release build can't serve a test ad. The release build also refuses to assemble while the ad identifiers are still placeholders. The alternative fails silently: the app ships, serves nothing, and the first sign is an empty earnings report.
- Full-screen ads showed whenever one happened to be loaded, so three quick failed rounds meant three full-screen ads in a few minutes. They're now at least 90 seconds apart, at most four per session, and none until the third round.
An audit checklist for inherited code
If someone hands you a codebase that "just needs a few tweaks", this is the list I'd start with:
- Read the product document against the code. Every promise is a test you can run by reading.
- Find the real range of every score and threshold. Can the top value actually happen?
- Generate content in bulk and count. Patterns hide in single samples.
- List what other apps can open. Check every
exportedactivity, service and receiver. - Ask what the first schema change will do to existing users' data.
- Split debug and release for ads, keys and anything else that touches money or users.
- Replace the inherited identity: app id, privacy URL, store listing details.
- Look for duplicated code, and fix every copy, or better, delete all but one.
None of this needs the app to crash first. That's the point. The worst bugs in a finished-looking app are the ones nobody has reported, because nobody can see them.
Frequently asked questions
- How do you audit an inherited or purchased app codebase?
- Read the code against what the product is meant to do, not against whether it runs. Check every score and threshold can actually be reached, simulate random content in bulk to look for patterns, list which screens other apps can open, and check what happens on the first database change. Then replace the template's identity: app id, privacy policy URL and ad identifiers.
- What does android:exported mean?
- It decides whether other apps on the device can start an activity directly. An activity that is only reached from inside your own app should say android:exported="false". Exposing it lets any installed app open that screen, including in a state your code never expected.
- Why test random question generators with a simulation?
- Patterns in generated content are invisible one question at a time. Generating many thousands and counting where the correct answer lands shows a bias in seconds, such as the answer always being the second smallest option.