Talk to Arduino and ESP32 boards from Flutter over USB OTG, WiFi TCP sockets, or Bluetooth LE, without hitting the six traps that burn a whole weekend.
Open-source fork (Android 12–14)
usb_serial_for_android
Fixes AGP 8/9 namespace builds, Android 12 and 14 PendingIntent and receiver export flags, leaked probe connections, and a generic serial terminal example with line framing tests.
One small BoardLink interface with WifiLink (dart:io TCP socket) and BleLink (Nordic UART Service via universal_ble), plus ESP32 sketches and socket tests against a fake board.
Verification note: both repos pass flutter analyze, unit tests, and fresh APK builds; as noted in their READMEs, the updated Android 14 permission path and wireless sketches have not been re-verified on physical boards yet. Open an issue or email me if you test on hardware.
Android device_filter.xml Vendor IDs
Android’s device_filter.xml requires decimal vendor IDs, not hex. Put the decimal column in vendor-id="...".
Board / USB bridge
Hex
Decimal (for XML)
Espressif native USB (ESP32-S2/S3/C3)
0x303A
12346
WCH CH340 / CH341
0x1A86
6790
Silicon Labs CP210x
0x10C4
4292
FTDI FT232R / FT2232
0x0403
1027
Prolific PL2303
0x067B
1659
Arduino LLC
0x2341
9025
Raspberry Pi RP2040
0x2E8A
11914
5-minute ESP32 troubleshooting table
ESP32 sends nothing back over USB (no error)
Native USB boards running TinyUSB discard output until the host asserts DTR. Call setDTR(true), wait ~1 second, and always call listen() before connect() so the native read loop actually starts.
Build fails with "Namespace not specified" on AGP 8+
Most pub.dev USB serial plugins stopped updating in 2022. Use a fork that declares namespace in build.gradle and targets compileSdk 35+.
USB permission dialog crashes on Android 12 or 14
PendingIntent needs FLAG_MUTABLE on API 31+, setPackage(packageName) to stay explicit on Android 14, and RECEIVER_NOT_EXPORTED on API 33+.
JSON replies fail jsonDecode halfway through
USB, TCP sockets and BLE all deliver arbitrary byte chunks. Never parse a chunk: buffer until newline (\n or \r\n) and ignore firmware debug lines.
BLE messages stop at exactly 20 characters
BLE notification payload is MTU minus 3 bytes (23 - 3 = 20 by default). Request a larger MTU after connecting, or frame lines across packets.
WiFi TCP socket works in debug, fails in release APK
Flutter only puts android.permission.INTERNET in the debug manifest. Add it explicitly to android/app/src/main/AndroidManifest.xml.
Watch the step-by-step walkthrough
Prefer a video? Here is the 9-minute Android USB serial tutorial covering the manifest, device_filter.xml, line framing, and the DTR trap.