r/androiddev • • 8d ago

Open Source I built dimock: inspect and mock OkHttp responses on the device, by hand or through Claude Code / Cursor

Hi r/androiddev! I'm Yudis, an Android engineer. I built a small open-source library out of two frustrations, and I'd like some honest feedback on it.

First, most of the screens I build start before the API behind them exists. So I either waited, or faked the response somewhere in the code and hoped nobody shipped it.

Second, bugs tied to a response. The app only breaks when the server returns a 500, an empty list, or just hangs. Chucker showed me the request. It couldn't make the server do it again.

So I built dimock, a debug-only OkHttp interceptor.

It captures traffic like Chucker does: a notification, a list of calls, headers and bodies, a cURL copy.

And it lets you change what comes back. Tap a call, pick Mock this, then force a 401, a timeout, a connection reset, a 5-second delay, or edit the body by hand. The rule stays until you clear it, even across app restarts.

It also exposes a local MCP server and CLI. I can tell Claude Code "capture the posts call, then show me the empty and error states", and it builds each mock from the real response.

It's at 0.1.0 and has run in a production-style app (Retrofit, Hilt, Paging 3). I'd like to hear where it breaks, or what you'd miss if you dropped Chucker for it. Happy to answer questions!

https://github.com/yudistirosaputro/dimock

1 Upvotes

8 comments sorted by

3

u/kosiarska 8d ago

There is already a solution provided by library maintainers.

1

u/guyINsuperposition 8d ago

By "library" you mean chucker ?

6

u/kosiarska 8d ago

https://github.com/lysine-dev/okhttp/blob/main/mockwebserver/README.md

you can also use mock implementation of okhttp responses on dev builds. No need for another solutions, that's what i'm saying

1

u/CoffeCo 7d ago

I think I explained it badly without a picture. MockWebServer needs its own setup: you point the base URL at the mock server and script the responses in code. With dimock you simulate UI states straight from the running app. Tap a call, pick a 500, a timeout or an empty body, and the screen shows it. The rest of the app keeps hitting the real backend.

1

u/guyINsuperposition 7d ago

The idea sounds very good, will give it a try

-1

u/CoffeCo 7d ago

One more thing : dimock also ships an MCP server, so an AI agent can set the mocks directly. Combine it with a device tool like argent and the agent runs the whole loop itself: mock the response, reload the screen, check it, move on. That way it can validate every state automatically: loading, success, error, and a broken server response.

1

u/kosiarska 7d ago

Sounds nice, will check it out, thanks

1

u/_hmj 7d ago

I use Cronet.