MacOS Mojave下adb devices反复挂起无法识别设备求助
Hi Tom, sorry to hear you're stuck with this frustrating adb hang issue—killing the 5037 port process working once but failing again definitely points to a persistent problem with the adb daemon or system permissions. Let's walk through targeted fixes tailored to your Mojave environment:
Step 1: Fully Purge All ADB Processes
Killing just the 5037 port process might leave lingering adb instances that cause the daemon to misbehave again. Use these commands to wipe all adb-related processes clean:
- List all adb processes:
ps aux | grep adb - Kill each process with the PID shown:
kill -9 <PID_NUMBER> - Or use a one-liner to kill all adb processes at once:
pkill -f adb
After this, run adb kill-server to ensure the daemon is fully stopped before restarting.
Step 2: Fix ADB Permissions with Sudo
Mojave's security restrictions often block adb from accessing USB devices properly. Try launching the adb server with elevated privileges:
- Run
adb kill-serverto stop any running daemon - Start the server with sudo:
sudo adb start-server - Now run
adb devices—if this works consistently, the issue was a permission bottleneck. Note that you may need to usesudofor subsequent adb commands, or adjust your user's USB permissions (see Step 3).
Step 3: Verify USB Device Permissions in System Preferences
Mojave requires explicit permission for apps to access USB devices. Here's how to check:
- Open System Preferences > Security & Privacy > Privacy tab
- Scroll down to USB in the left sidebar
- Look for entries related to "Android Debug Bridge" or "platform-tools"—make sure the checkbox next to them is enabled
- If you don't see the entry, try re-plugging your Android device and running
adb devicesagain; this should trigger a permission prompt that you need to approve.
Step 4: Update ADB to the Latest Compatible Version
Older adb versions can have compatibility bugs with Mojave. Update your platform-tools:
- If you use Android Studio, open the SDK Manager > SDK Tools and check for updates to "Android SDK Platform-Tools"
- Alternatively, download the latest platform-tools package for macOS, unzip it, and replace your existing adb executable (usually located in
~/Library/Android/sdk/platform-tools/)
Step 5: Troubleshoot USB Connection Issues
Flaky USB connections can cause adb to hang unexpectedly:
- Switch to a high-quality USB data cable (charging-only cables won't work for debugging)
- Try a different USB port on your Mac (preferably a USB 2.0 port, as some USB 3.0 ports have compatibility issues with Android devices)
- On your Android device, ensure USB Debugging is enabled in Developer Options, and select File Transfer (MTP) or PTP mode when prompted after connecting.
Step 6: Rule Out Third-Party Software Conflicts
Third-party tools like USB managers, antivirus software, or VPNs can interfere with adb's communication. Temporarily disable these apps, then repeat the adb process (kill server, start server, run adb devices) to see if the hang issue goes away.
If none of these steps work, you can try resetting your adb configuration by deleting the .android folder in your home directory (rm -rf ~/.android), then restarting the adb server. Just note this will wipe any saved adb device authorizations, so you'll need to re-approve your device's debugging prompt.
内容的提问来源于stack exchange,提问作者Tom Taylor

