Skip to content

Connect with adb and Android Studio

pocketshare connect makes a rented phone appear in adb devices on your computer. Android Studio, Logcat, adb install, adb shell, port forwarding and scrcpy then work as they do with a phone on your desk.

Download pocketshare for your platform (Install) and put it on your PATH. You also need adb (Android SDK platform-tools, which Android Studio installs).

Terminal window
pocketshare login

login shows a code and a link. Open the link on pocketshare.io, check that the code matches and approve it; the CLI stores a key for your account. In CI, set POCKETSHARE_API_KEY instead.

Terminal window
pocketshare phones search --android ">=13" --max-price 5
pocketshare rent <phone-id> --max-spend 2
pocketshare connect <rental-id>

Every rental needs a spending cap (--max-spend, in dollars): the rental ends when it reaches it. pocketshare rent … --connect rents and connects in one step, and pocketshare connect with no rental connects to your only active rental.

connect waits until the host’s hub has prepared the phone, then prints:

Connected to Pixel 7 for rental 0b3c….
ADB endpoint: 127.0.0.1:15600 (added to adb devices)
Use it with: adb -s 127.0.0.1:15600 shell, Android Studio's Running Devices, scrcpy -s 127.0.0.1:15600
Key check: your adb key only; relay round trip 38 ms
Press Ctrl-C to disconnect. The rental keeps running until `pocketshare stop`.

Keep it running while you work. Ctrl-C disconnects your computer, but the rental and its billing continue until you stop it.

While connect runs, the phone is in Android Studio’s device menu next to your emulators, named after its model. Pick it and choose Run to install and start your app, or Debug to attach the debugger; Logcat shows its log, and Running Devices mirrors its screen.

The CLI runs adb connect with Android Studio’s own adb when it finds the SDK (%LOCALAPPDATA%\Android\Sdk, ~/Library/Android/sdk or ~/Android/Sdk, or $ANDROID_HOME), so both see the phone. If Android Studio doesn’t list it, check that adb devices shows 127.0.0.1:<port>, or pass the adb Android Studio uses with --adb PATH.

Option What it does
--port N Use this local port for the ADB endpoint (by default the same port each time for a rental, so the adb serial survives a reconnect)
--adb PATH The adb to run adb connect with
--no-adb-connect Open the endpoint without running adb connect
--any-key Accept any local adb client, not just your adb key
--json One JSON line per event, for scripts

Checked end to end so far: adb install, shell, logcat, push and pull, forward and reverse. Android Studio, scrcpy and test frameworks use the phone through the same adb connection; their full check on real phones is still in progress, so tell [email protected] if one misbehaves.

  • Android Studio: Run, the debugger, Logcat, the profiler and Running Devices mirroring.
  • adb install, adb shell, adb push and pull, adb logcat.
  • adb forward to ports on the phone, and adb reverse to ports on your computer (for a development server or Metro).
  • scrcpy and test frameworks such as Espresso, Appium and Maestro.

Not available: adb root, remount, rebooting into the bootloader or recovery, adb backup and switching adb to TCP/IP. Commands for these fail with a message saying so.

Only your adb key (~/.android/adbkey.pub) can use the endpoint, so other programs and users on your computer can’t reach the phone.

Terminal window
pocketshare stop
pocketshare usage

Stopping cuts access within seconds and ends billing. The phone is then wiped back to the state it had before your rental: apps you installed, files, settings and port forwards are removed and the phone restarts. Copy anything you need off the phone before you stop.

A rental also ends when it reaches its spending cap or your credit runs out, or if the host has to stop hosting; connect prints the reason.