DEV Community

Cover image for MTP on Android Is a Minefield — What I Learned After Building My Own Mac Client
hiyoyo
hiyoyo

Posted on

MTP on Android Is a Minefield — What I Learned After Building My Own Mac Client

I built HiyokoMTP because the existing tools kept failing me.

Android File Transfer has been effectively abandoned. OpenMTP is Electron-based — which means every USB operation runs through JavaScript, and its device recognition layer differs fundamentally from a native implementation. So I wrote my own MTP stack in Rust using nusb.

(All tests run on an 8-year-old MacBook Air — if it works there, it works anywhere.)


Why Existing Tools Fall Short

  • Android File Transfer: no longer actively maintained, frequently fails to recognize modern Android devices.
  • OpenMTP: every USB operation runs through the Electron runtime; its device recognition approach differs from native, leading to inconsistent behavior across manufacturers.

The 5 MTP Landmines

1. Manufacturer quirks

Pixel, Samsung, and Xiaomi all behave differently. Xiaomi defaults to "charging only" mode on connect; switching modes mid-session can silently terminate the MTP session.

2. The 4 GB wall

MTP uses 32-bit object size counters. Files over 4 GB require special handling, or transfers silently corrupt.

3. Special characters

Filenames containing \ / : * ? " < > | must be sanitized before transfer. No sanitization = silent error or crash.

4. Cable-pull at 90%

Unplugging during a transfer is the most common user mistake. Without clean disconnect detection, the app crashes or enters an undefined state.

5. USB hub instability

Hubs introduce instability. MTP is far more sensitive to this than mass storage protocols. Always test through a hub.


If you're building your own MTP client, plan for these edge cases — they're invisible until a real user hits them.

Building HiyokoMTP forced me to handle every one of these cases explicitly. All of the above is baked in. One-time purchase, no subscription.

https://hiyokomtp.lemonsqueezy.com/checkout/buy/2e966b64-554e-42a0-b865-4240281978a1

What's the weirdest USB/MTP behavior you've run into?

Top comments (1)

Collapse
 
hiyoyok profile image
hiyoyo

TL;DR: Existing MTP tools on Mac are either abandoned or Electron-based. I built my own in Rust and learned 5 things the hard way.