pythonandroidshellbluestacks

Why does my Python code ppadb not connect to Memu? From cmd line can adb to Memu. Bluestacks adb python code works but not Memu


I have Memu and Bluestacks running on my computer. I am fully interacting with adb on bluestacks. But I am unable to connect to Memu with my python code using ppadb.

If I use the windows and command line "adb -s 127.0.0.1:21503 shell" I can access Memu and same for Bluestacks using "adb -s emulator-5554 shell"

Using this Python code and I can connect to Blue Stacks and interact (eg screencap)

import ppadb
from ppadb.client import Client

adb = Client(host='127.0.0.1', port=5037)
#adb = Client()
print(adb.version())
print("getting list of devices")
devices = adb.devices()
for onedevice in devices:
    print(str(onedevice))
print("connecting to Memu")
device = adb.device("emulator-5554")
print("connected")

I using the following windows command line command to connect to Memu "adb connect 127.0.0.1:21503"

output from "adb devices -l" is the following

C:\Program Files\Microvirt\MEmu>adb devices -l
List of devices attached
emulator-5554          device product:OnePlus5 model:ONEPLUS_A5000 device:OnePlus5
127.0.0.1:21503        device product:A5010 model:A5010 device:A5010

I am using the following python code to try to connect to Memu and it just hangs.....

import ppadb
from ppadb.client import Client

adb = Client(host='127.0.0.1', port=21503)
#adb = Client()
print(adb.version())
print("getting list of devices")
devices = adb.devices()
for onedevice in devices:
    print(str(onedevice))
print("connecting to Memu")
device = adb.device("127.0.0.1:21503")
print("connected")

One would think that If I can interact with the shell of Memu then I should be able to connect via Python.

Is there anything obvious I am doing wrong?


Solution

  • Connect to adb server not to the device

    adb = Client(host='127.0.0.1', port=5037)