AttributeError: 'NoneType' object has no attribute 'shell'
Traceback (most recent call last):
File "Serial.py", line 5, in
I am getting this error when trying to run this code on linux from ppadb.client import Client as AdbClient
Default is "127.0.0.1" and 5037
client = AdbClient(host="127.0.0.1", port=5037) device = client.device("emulator-5554") device.shell("echo hello world !") inside Serial.py
Am I missing anything?
Hi @iverdr17
You can use adb -H 127.0.0.1 -P 5037 devices to check the device emulator-5554 is existing or not.
When the device emulator-5554 is not existing, client.device("emulator-5554") will return None
Hi @Swind List of devices attached DHE4C18C10003341 device This is what I am getting for adb -H 127.0.0.1 -P 5037 devices. That means I am connected with the device. The attribute error still exists when device.shell("echo hello world !") this is run. Not only that when I am trying to run the following code for reading logcat
from ppadb.client import Client def dump_logcat_by_line(connect): file_obj = connect.socket.makefile() for index in range(0, 10): print("Line {}: {}".format(index, file_obj.readline().strip()))
file_obj.close() connect.close()
client = Client() device = client.device("emulator-5554") device.shell("logcat", handler=dump_logcat_by_line)
The attribute error comes for file_obj, connect and shell.
Hi @iverdr17
List of devices attached
DHE4C18C10003341 device
The device emulator-5554 is not existing in the device list.
If you want to connect to your device DHE4C18C10003341
You should use
client = Client()
device = client.device("DHE4C18C10003341")
Hi @Swind Its working now. Is there any way to sort the data by TAG and then print. Thank you.
import ppadb
from ppadb.client import Client as AdbClient
adb = AdbClient(host='127.0.0.1', port=5037) print(adb.version()) print("getting list of devices") print(adb.devices()) print("connecting to Memu") device = adb.device("127.0.0.1:21503") print("connected") device.shell("echo hello world !")
error: AttributeError: 'Client' object has no attribute 'shell'
are you trying to connect to an emulator?
Normally the adb.device("") would contain the serialnumber or the ip address with port 5555.
the print("connected") is not valid. You should always check that device is not None