Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

UnicodeDecodeError when running demo code #52

Closed
dov opened this issue Jul 9, 2017 · 6 comments
Closed

UnicodeDecodeError when running demo code #52

dov opened this issue Jul 9, 2017 · 6 comments

Comments

@dov
Copy link

dov commented Jul 9, 2017

Trying to run the demo code:

import os.path as op

from adb import adb_commands
from adb import sign_m2crypto

# KitKat+ devices require authentication
signer = sign_m2crypto.M2CryptoSigner(
    op.expanduser('~/.android/adbkey'))
# Connect to the device
device = adb_commands.AdbCommands.ConnectDevice(
    rsa_keys=[signer])
# Now we can use Shell, Pull, Push, etc!
for i in xrange(10):
  print device.Shell('echo %d' % i)

Fails as follows:

$ env PYTHONPATH=/space/pub-repos/python-adb:$PYTHONPATH python adb-demo.py
Traceback (most recent call last):
File "adb-demo.py", line 11, in
rsa_keys=[signer])
File "/space/pub-repos/python-adb/adb/adb_commands.py", line 76, in ConnectDevice
return cls.Connect(handle, **kwargs)
File "/space/pub-repos/python-adb/adb/adb_commands.py", line 99, in Connect
device_state = cls.protocol_handler.Connect(usb, banner=banner, **kwargs)
File "/space/pub-repos/python-adb/adb/adb_protocol.py", line 298, in Connect
msg.Send(usb)
File "/space/pub-repos/python-adb/adb/adb_protocol.py", line 211, in Send
usb.BulkWrite(self.Pack(), timeout_ms)
File "/space/pub-repos/python-adb/adb/adb_protocol.py", line 198, in Pack
len(self.data), self.checksum, self.magic)
File "/space/pub-repos/python-adb/adb/adb_protocol.py", line 182, in checksum
return self.CalculateChecksum(self.data)
File "/space/pub-repos/python-adb/adb/adb_protocol.py", line 190, in CalculateChecksum
total = sum(map(ord, data.decode('ascii')))
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8d in position 1: ordinal not in range(128)

I'm using the latest git commit.

$ git log --oneline -1
bed1a53 Bump to 1.2.0 and add a History section (#46)

Mobile phone is google pixel running Android 7.1.2 .

@oxesoft
Copy link

oxesoft commented Jul 10, 2017

the same here

@wenxin3262
Copy link

Any update on this issue?
I am running on a custom fix that from #47

@forlayo
Copy link

forlayo commented Aug 17, 2017

Same here, any news on this ?

@eismog
Copy link

eismog commented Sep 14, 2017

I have the same problem

@geckogecko
Copy link

+1 I got the same error

@gauravkatoch007
Copy link

gauravkatoch007 commented Sep 23, 2017

+1, I got the same error.
I also tried converting -
https://github.com/google/python-adb/blob/master/adb/adb_protocol.py#L190

total = sum(map(ord, data.decode('ascii')))
to
total = sum(map(ord, data.decode('utf-8')))

But still faced the same issue. I tried re-generating my adb keys as well, didn't help.
Works fine with adb in shell.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants