Support me on Patreon to write more tutorials like this!

I spent two stretches, two days on one and about a week on the other, trying to make two mobile apps' request-signing libraries work without a phone. The plan was the same both times: load the app's native library into an emulator on a laptop, answer every question it asks, and compare what it produces with what a real device produces.
Neither project reached its goal. Both ended with a written verdict that they were closed on measurement and not on judgement, and with a lot of material that is not the interesting part. This post is about the interesting part: how often the thing I was looking at was my own tooling, and the small mechanism that stopped me from losing track of it.
I'm leaving out the apps' names and anything about how their signing works. That isn't what I learned.
TL;DR
- The first project ended in a note titled "measured negative". The acceptance call was attempted and refused, with nothing substituted for the missing result. My harness had stood in for the real device five times before I noticed.
- The second project ended with a 251-section dossier whose final verdict, dated 2026-11-19, says the emulator route is closed on measurement. Five candidate explanations for the gap were each located and then refuted.
- In the second project I misread bits of an unknown buffer as meaningful state eight times. Eight times I was wrong.
- I kept a retraction ledger of every claim that later failed, about 73 rows by my count (38 retracted, 20 refuted, 11 void, 4 provisional), and a script that fails if the ledger and the dossier disagree. It has a self-test that plants a missing entry and checks that it is caught.
- The rules that would have saved the most time are cheap: identify a data structure before interpreting its bits, decode the final artifact before diagnosing its producer, and give every instrument a positive control.
The shape of both projects
The device-free idea is simple to state. If an app signs its requests with a native library, and you can run that library somewhere you control, you can produce signed requests without a phone. In practice you are emulating an environment the library was built to inspect: Java classes it looks up by name, files it expects to find on disk, system calls it makes, and memory it reads back later.
That means every observation passes through a stack of my own making: the emulator, my stubs for the pieces of Android it doesn't have, the hooks I use to watch calls, and the scripts that compare results with a real device. When something looks wrong, there are many places the wrongness can live, and most of them are mine.
How they ended
The first project's final note says it plainly. The acceptance call returned null with an error code, and I had not substituted a result to make it look better. The larger part of the note is what matched. The warm sequence of native commands matched the device command-for-command up to a point. The load-phase calls into Java were an exact prefix of the device's: 109 of 109 calls other than exception checks identical, and all 29 class lookups in the same order. The first divergence in the init chain was a single command that returns bytes on the device and null on the host, and the knobs I tried against the next divergence all measured negative.
The second project ended on the same shape from the other side. My harness loaded and drove the real library with no Android runtime, answered every Java question the library asked, and produced output that was structurally close to the device's own. The gateway only ever accepted a longer form that the harness never produced, and nothing I could still measure explained why. The final verdict lists the five candidate explanations in the order I eliminated them. Each one was located, and then each one was refuted by a measurement. It ends with the statement that no remaining anomaly in the harness's output is measurable.
Closing on measurement matters because it tells the next person what not to repeat. "We ran out of ideas" doesn't do that. "Here is every candidate and how it died" does.
The instrument was the bug
This is the part I'd tell someone starting a similar project, and I only really saw it by reading the two records side by side.
A swallowed exception looks like a null. In the first project, the emulator turned an unmapped memory fetch inside a native-to-Java call into a null result. A crash and a refusal were indistinguishable. Every "returned null" I had written down before exception surfacing was in place was invalid, and that produced six rounds of concluding that a command "does nothing".
My harness stood in for the device, five times. My notes list them: a hook-status return, a loader call made with one argument, a stale fake errno, class lookups that the emulator auto-created whatever the name, and a replay list that silently substituted the device's captured return for one command. That last one meant "that command returns null on the host" was a statement about my replay layer. When I fixed the last one, the result got stronger, because it was now native. But everything earlier in the note had to be re-read.
A correct-looking disassembly refuted my reading. A function returned an error after listing a directory, and I first read that as a state-gated failure inside the library. Disassembling the code after the call showed it branches on the pointer it receives and only takes the success path if that pointer is non-null. My shim had returned a genuine 16-entry listing, but the pointer never reached the caller's register. The blocker was my return-value plumbing, which meant a route I had written off as exhausted was open again.
The retraction ledger for the second project has the same pattern in different words:
| What I concluded | What it turned out to be |
|---|---|
| A Java runtime is unavailable, so a header can't be observed | The instrumentation toolkit's Java bridge was mis-installed |
| No signing library is loaded | My load hook attached too late |
| The emulator opens no file during initialisation | My instrument never fired, and a control open bypassed the resolver |
| Feeding the real stored key has no effect | The value never reached the library, because I used the wrong dispatch variant |
| Non-empty inbound headers crash, because the emulator can't walk a Java collection | My own dispatch matched a generic prefix before the specific method and returned null |
| The decisive difference is an argument that is 96 on the device and 4 in the harness | The 4 came from a different call site |
None of these were exotic. Each was a measurement whose tool I hadn't tested.
Eight times I read bits as meaning
The second project's last section lists eight times I took bits of an unknown buffer for semantic state:
| I thought it was | It was |
|---|---|
| a text fragment from the environment | an unrelated string constant |
| a structured certificate object | certificate bytes sitting in the image |
| per-session values | identical constants |
| deterministic constants | an inline log message |
| saved registers | heap pointers, then ASCII bytes of a base64 string |
| a difference in a staging buffer | nothing: the emitted output was already right |
| a precomputed signature | a shared scratch region reused for unrelated data |
| a mode-selector bit | a string's allocation flag |
The two rules that would have prevented all eight are short. Identify the data structure before interpreting its bits. And always decode the final artifact before diagnosing the code that produces it. One of the eight cost rounds because I analysed a staging buffer when the thing the library actually emitted was already correct.
A ledger with a checker
By the end of the second project I had a long dossier with claims that later failed, and I kept losing track of which were still standing. So I started a retraction ledger. Each row is a claim as it was written, the section whose measurement settled it, and a status: retracted (wrong), refuted (tested and failed), void (no evidence either way) or provisional (unverified). My count at the time of writing is 38 retracted, 20 refuted, 11 void and 4 provisional.
A ledger rots, so I wrote a short script that checks it in both directions. Every section the ledger cites has to exist in the dossier, and every dossier section that marks itself retracted, refuted, void or provisional has to appear in the ledger. The script fails if either direction breaks. Because "a check nobody tests is a guess", it has a self-test that builds a tiny dossier with an unindexed retraction and confirms the checker catches it. It runs as part of a gate of fourteen checks, and the final verdict says it caught two omissions live in the last session.
I ran it again before publishing this, and it passes. It reports 65 rows, because it only counts rows whose first cell is a plain section number, which is why that doesn't match my count of the table. It has limits. It checks sections, not prose. The ledger's own header said it covered about 117 sections while the dossier had 251, and the checker never noticed. A ledger can be perfectly in sync and still describe itself wrongly.
The rules I'd keep
- Give every instrument a positive control. Before trusting that a hook saw nothing, make it see something you caused. Two of my "void" ledger rows are exactly this: a control that failed, and a write test whose value was already zero.
- Treat a null or default return as "unknown". A stub, a swallowed exception and a genuine refusal look the same.
- Record the observation and the probe target, not a causal claim. "A call jumps through a zeroed slot" is a fact. "The import is unresolved" was a guess that happened to be wrong.
- Index your retractions, and make the index fail loudly. I would not have trusted my own dossier without it.
- Say which route is closed and why. The first project's note and the second project's verdict both end with what a successor shouldn't repeat.
What I don't know
Neither project established that the goal is impossible. The second verdict names two routes that remain, a containerised Android runtime running the real app, or a device-resident signer for one header, and says neither is an emulator change. I don't have a count of rounds that is consistent across the two projects, and I didn't record how much time each round took, so I can't say what any of this cost. The ledger counts above are my own count of the table's rows today. The dossier's closing section gives 88 rows (40 retracted, 20 refuted), which doesn't match.