ADB (Android Debug Bridge) is a universal command-line tool for connecting computers and Android devices. Each LDPlayer instance is exposed through an ADB debugging port. Developers can directly use adb to handle connections, installations, simulated inputs, screenshots, file transfers, and all debugging and automation tasks without relying on any proprietary command-line wrappers.
I. LDPlayer adb Port and Connection
1. Checking the adb port
Each LDPlayer instance is exposed through a set of ADB debugging ports. The standard naming convention is:
| Instance Number | Default adb port |
|---|---|
| 0 (Main instance) | 5554 |
| 1 | 5556 |
| 2 | 5558 |
| … | Sequentially +2 |
After instance 0 starts, it typically appears in adb devices as a serial number (e.g., emulator-5554).
When running multiple instances, instance 1 roughly corresponds to emulator-5556, and instance 2 roughly corresponds to emulator-5558. The specific serial number is subject to the actual output of adb devices on the local machine.
adb devices # Check the serial numbers of all instances on the local machine
Port conflict warning for running dual LDPlayers (LDPlayer 9 + LDPlayer 14) on the same machine: If Instance 0 of both LDPlayer 9 and LDPlayer 14 run simultaneously on the same computer, both will attempt to seize
5555. The instance that starts first registers normally, while the adb port of the instance starting later will be suppressed and invisible inadb devices.Solution: Avoid running Instance 0 of both simultaneously, or keep only one emulator version running.
2. How to connect adb (Single instance)
- Open the LDPlayer installation directory (e.g.,
E:\LDPlayer\LDPlayer14), typeCMDin the address bar, and press Enter to call up the command prompt. - Type
adb devicesand press Enter to confirm the instance is listed (e.g.,emulator-5554). - Type
adb shelland press Enter to enter the Android shell.
E:\LDPlayer\LDPlayer14> adb devices
List of devices attached
emulator-5554 device
E:\LDPlayer\LDPlayer14> adb shell
xxx:/ #
3. How to connect adb for multi-instance emulators
When multiple instances are running simultaneously, each instance will register its own serial number. First, use adb devices to check all serial numbers, then use -s <serial number> to specify the target:
adb devices # First check all serial numbers
adb -s emulator-5554 shell # Connect to instance 0
adb -s emulator-5554 shell pm list packages -3
If the serial number does not appear, first confirm that the corresponding emulator instance has started, and then execute adb devices to refresh.
II. Multi-device Conflicts and Targeting with -s
When a computer is connected to multiple emulators (or multiple instances) simultaneously, any adb command without -s will report an error:
adb.exe: more than one device/emulator
There is only one solution: always use -s <serial number> to explicitly specify the target device. Simply use the serial number as the first parameter for adb:
adb -s emulator-5554 shell input tap 500 500
About the stability of serial numbers: The serial number of a running instance (e.g.,
emulator-5554) is continuously maintained by the LDPlayer adb server. After anadb disconnect, it will automatically reconnect within a few seconds. To completely disconnect, you must close the instance or runadb kill-server(however, running any adb command again will re-register it). Therefore, directly using-sto lock onto the real serial number fromadb deviceswithin your scripts is the most hassle-free approach.
III. Common ADB Commands Guide
Some commands involve permissions, so you can enable ROOT (see 3.1) before proceeding. The following examples assume you have already entered Android via adb shell, or added the prefix adb -s <serial number>.
1. Enable ROOT permission
Open the emulator "Settings Center → Other → Enable ROOT permission". After connecting via adb, type adb shell; if the prompt is $, the permissions are insufficient:
adb shell # See $ upon entering
exit # Return to the previous level
adb root # Restart adb daemon as root
adb shell # Enter again, prompt should be #
2. Operation format under multiple devices
adb -s <serial number> <other commands>
# Example:
adb -s emulator-5554 shell pm list packages -3
If there is only one emulator on the local machine, you can omit the -s and directly use adb <command>.
3. Install and uninstall apk
adb install C:\xx.apk # Install
adb install -r C:\xx.apk # Overwrite install (keep data)
adb uninstall <package_name> # Uninstall
4. Get installed application package names
adb shell pm list packages # All applications
adb shell pm list packages -3 # Third-party applications
adb shell pm list packages -s # System applications
adb shell dumpsys window | findstr mCurrentFocus # Currently running application
5. Get Activity name
adb shell cmd package resolve-activity --brief <package_name> | tail -n 1
6. View application version number
adb shell dumpsys package <package_name> | findstr version
7. Clear application data
adb shell pm clear <package_name>
8. Simulate input
| Action | Command | Description |
|---|---|---|
| Keypress | adb shell input keyevent | E.g., 3 is the HOME key, 4 is the Back key |
| Character | adb shell input text | E.g., hello; Does not support Chinese |
| Tap/Click | adb shell input tap | X Y are screen coordinates (pixels) |
| Swipe | adb shell input swipe [TIME] | TIME is in milliseconds, default 100 |
| Long press | adb shell input swipe | Having the same start and end points acts as a long press |
| Launch App | adb shell am start -n / | See 3.5 to obtain the Activity name |
9. Transfer files between computer and emulator
adb push C:\test.apk /sdcard/ # Computer → Emulator
adb pull /sdcard/test.apk C:\ # Emulator → Computer (Use Windows drive letter, do not use /c/)
Tested and verified: On LDPlayer 9 / LDPlayer 14, native
adb push/adb pullboth function normally for file transfers (tested bidirectional success with the same file). Use a Windows drive letter (e.g.,C:\) instead of/c/for the target path.
10. Screenshot
adb shell screencap /sdcard/screen.png # Capture current screen, save to device
adb pull /sdcard/screen.png C:\ # Download to computer
11. Record video
adb shell screenrecord /sdcard/test.mp4 # Start recording
# Press CTRL+C to stop
adb pull /sdcard/test.mp4 C:\ # Export
12. View device information
adb shell getprop ro.product.model # Model
adb shell getprop ro.product.brand # Brand
adb shell getprop ro.product.board # Processor
adb shell getprop ro.build.version.release # Android version
adb shell wm size # Resolution
adb shell dumpsys SurfaceFlinger | findstr "GLES" # Render mode
13. Disable developer mode
adb shell settings put global development_settings_enabled 0
IV. adb Practical Examples
By combining the commands above, you can achieve complete automation of the LDPlayer. Common scenarios:
| Goal | Command |
|---|---|
| Single instance tap coordinate | adb shell input tap 500 500 |
| Specific instance tap coordinate | adb -s emulator-5554 shell input tap 500 500 |
| Input English text | adb shell input text hello |
| Swipe action | adb shell input swipe 300 800 300 300 500 |
| Return to home screen | adb shell input keyevent 3 |
| Check Android version | adb shell getprop ro.build.version.release |
| Launch system settings | adb shell am start -n com.android.settings/.Settings |
| Screenshot and export | adb shell screencap /sdcard/s.png followed by adb pull /sdcard/s.png C:\ |
| Push file to device | adb push C:\conf.txt /sdcard/ |