openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.38k stars 1.37k forks source link

Invalid version #906

Closed UzairJerry closed 5 months ago

UzairJerry commented 1 year ago

whenever i start uiautomator for the first time its works fine but after that it gives me invalid version error so when i uninstall atx app and retry it works fine ... i have to uninstall atx app everytime now

photo_2023-08-23_11-42-32

/usr/local/bin/python3.11 /Users/itiesoft/PycharmProjects/finance-bot/test/test_mb.py [D 230824 12:56:54 init:661] [pid:7776] [5477ce91] kill process(ps): uiautomator Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 486, in _jsonrpc_retry_call return self._jsonrpc_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 519, in _jsonrpc_call raise GatewayError( uiautomator2.exceptions.GatewayError: (<Response [502]>, 'gateway error, time used 0.0s')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/itiesoft/PycharmProjects/finance-bot/test/test_mb.py", line 66, in d.xpath(password).wait(timeout=60) File "/usr/local/lib/python3.11/site-packages/uiautomator2/xpath.py", line 559, in wait if self.exists: ^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/xpath.py", line 508, in exists return len(self.all()) > 0 ^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/xpath.py", line 449, in all xml_content = source or self._source or self._parent.dump_hierarchy() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/xpath.py", line 178, in dump_hierarchy self._last_source = self._d.dump_hierarchy() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), *kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/retry/api.py", line 73, in retry_decorator return __retry_internal(partial(f, args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/retry/api.py", line 33, in retry_internal return f() ^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 978, in dump_hierarchy content = self.jsonrpc.dumpWindowHierarchy(compressed, None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 479, in call return self.server._jsonrpc_retry_call(self.method, params, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 488, in _jsonrpc_retry_call self.reset_uiautomator(str(e)) # uiautomator可能出问题了,强制重启一下 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 640, in reset_uiautomator ok = self._force_reset_uiautomator_v2( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 667, in _force_reset_uiautomator_v2 if self._is_apk_required(): ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 711, in _is_apk_required if self._package_version("com.github.uiautomator.test") is None: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/uiautomator2/init.py", line 735, in _package_version return packaging.version.parse(m.group('name') if m else "") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/packaging/version.py", line 52, in parse return Version(version) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/packaging/version.py", line 198, in init__ raise InvalidVersion(f"Invalid version: '{version}'") packaging.version.InvalidVersion: Invalid version: ''

Process finished with exit code 1

clacknya commented 11 months ago

same problem with python 3.11

liaozd commented 11 months ago

same here, python3.11, and in ubuntu 23.04

clacknya commented 11 months ago

I found the solution: downgrading to uiautomator2-2.16.23 could fix it, which depends on packaging-20.9.

limerick1718 commented 11 months ago

I found the solution: downgrading to uiautomator2-2.16.23 could fix it, which depends on packaging-20.9.

For me, cannot fix…… Any updates or other solutions?

wrzssz commented 11 months ago

也可以这样

pip install packaging==21.3

或者降低uiautomator2的版本,或者降低packaging版本

limerick1718 commented 11 months ago

也可以这样


pip install packaging==21.3

或者降低uiautomator2的版本,或者降低packaging版本

是的!我发现了!解决办法就是这个!

iTheCreep commented 11 months ago

也可以这样

pip install packaging==21.3

或者降低uiautomator2的版本,或者降低packaging版本

神医啊,成功解决!

codeskyblue commented 5 months ago

fixed

vinhomesoceanpark commented 4 months ago

I am also suffering from this condition. I have downgraded the packaging to 20.9 or downgraded uiautomator2 but the problem still persists. Hope you check it out Screenshot 2024-04-28 115811

codeskyblue commented 4 months ago

uiautomator2 3.x fixed. Because the packaging lib is removed completely