故障

执行命令python -m uiautomator2 init,报错如下:

[D 2024-05-26 15:42:38,696 core:33 pid:6584] MockAdbProcess: b'onError: commandError=true message=INSTRUMENTATION_FAILED: com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner\n'
[D 2024-05-26 15:42:38,696 core:33 pid:6584] MockAdbProcess: b'android.util.AndroidException: INSTRUMENTATION_FAILED: com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner\n\tat com.android.commands.am.Instrument.run(Instrument.java:514)\nINSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner}\tat com.android.commands.am.Am.runInstrument(Am.java:196)\n\n\tat com.android.commands.am.Am.onRun(Am.java:80)INSTRUMENTATION_STATUS: id=ActivityManagerService\n\n\tat com.android.internal.os.BaseCommand.run(BaseCommand.java:56)\nINSTRUMENTATION_STATUS_CODE: -1\tat com.android.commands.am.Am.main(Am.java:50)\n\n\tat com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)\n\tat com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)\n'
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__main__.py", line 256, in <module>
    main()
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__main__.py", line 248, in main
    actions[args.subparser](args)
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__main__.py", line 29, in cmd_init
    d = u2.connect(dev)
        ^^^^^^^^^^^^^^^
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__init__.py", line 1135, in connect
    return connect_usb(serial)
           ^^^^^^^^^^^^^^^^^^^
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__init__.py", line 1151, in connect_usb
    return Device(serial)
           ^^^^^^^^^^^^^^
  File "D:\User\AppData\Python310\site-packages\uiautomator2\__init__.py", line 67, in __init__
    BasicUiautomatorServer.__init__(self, self._dev)
  File "D:\User\AppData\Python310\site-packages\uiautomator2\core.py", line 157, in __init__
    self.start_uiautomator()
  File "D:\User\AppData\Python310\site-packages\uiautomator2\core.py", line 170, in start_uiautomator
    self._do_start_uiautomator()
  File "D:\User\AppData\Python310\site-packages\uiautomator2\core.py", line 191, in _do_start_uiautomator
    self._wait_ready()
  File "D:\User\AppData\Python310\site-packages\uiautomator2\core.py", line 276, in _wait_ready
    self._wait_instrument_ready(launch_timeout)
  File "D:\User\AppData\Python310\site-packages\uiautomator2\core.py", line 242, in _wait_instrument_ready
    raise LaunchUiAutomationError(error_message, output)
uiautomator2.exceptions.LaunchUiAutomationError: ('INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner}\tat com.android.commands.am.Am.runInstrument(Am.java:196)', 'onError: commandError=true message=INSTRUMENTATION_FAILED: com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner\nandroid.util.AndroidException: INSTRUMENTATION_FAILED: com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner\n\tat com.android.commands.am.Instrument.run(Instrument.java:514)\nINSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.github.uiautomator.test/androidx.test.runner.AndroidJUnitRunner}\tat com.android.commands.am.Am.runInstrument(Am.java:196)\n\n\tat com.android.commands.am.Am.onRun(Am.java:80)INSTRUMENTATION_STATUS: id=ActivityManagerService\n\n\tat com.android.internal.os.BaseCommand.run(BaseCommand.java:56)\nINSTRUMENTATION_STATUS_CODE: -1\tat com.android.commands.am.Am.main(Am.java:50)\n\n\tat com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)\n\tat com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)\n')

描述:

试图令安卓设备安装atx-agent,失败

解决:

D:\User\AppData\Python310\site-packages\uiautomator2\assets\app-uiautomator.apk
D:\User\AppData\Python310\site-packages\uiautomator2\assets\app-uiautomator-test.apk

将上述2个apk手动复制到手机之中,然后安装


DEFAULT
19 声望2 粉丝