2

我正在尝试使用 Monkey Runner 中的层次结构查看器来查看我的 Android 应用程序的布局。当我调用device.getHierarchyViewer()方法时,我遇到了以下问题。

  E/hierarchyviewer: String index out of range: 1155
    130924 11:36:18.917:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
    ] Script terminated due to an exception
    130924 11:36:18.917:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions
    ]Traceback (most recent call last):
      File "F:\python\testing.py", line 311, in <module>
        pressButton ('id/action_bar_home_btn_area')
      File "F:\python\testing.py", line 86, in pressButton
        easy_device.touch(By.id(buttonID), MonkeyDevice.DOWN_AND_UP)
      File "F:\python\testing.py", line 86, in pressButton
        easy_device.touch(By.id(buttonID), MonkeyDevice.DOWN_AND_UP)
            at com.android.chimpchat.hierarchyviewer.HierarchyViewer.findViewById(Hi
    erarchyViewer.java:75)
            at com.android.monkeyrunner.easy.By.findView(By.java:72)
            at com.android.monkeyrunner.easy.EasyMonkeyDevice.getElementCenter(EasyM
    onkeyDevice.java:219)
            at com.android.monkeyrunner.easy.EasyMonkeyDevice.touch(EasyMonkeyDevice
    .java:85)
            at com.android.monkeyrunner.easy.EasyMonkeyDevice.touch(EasyMonkeyDevice
    .java:81)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)

    java.lang.RuntimeException: java.lang.RuntimeException: Could not dump view

对此的任何帮助表示赞赏。

4

1 回答 1

0

你可以试试AndroidViewClient dump

usage: dump [OPTION]... [serialno]

Options:
  -H, --help                       prints this help                             
  -V, --verbose                    verbose comments                             
  -I, --ignore-secure-device       ignore secure device                         
  -F, --force-view-server-use      force view server use (even if UiAutomator present)
  -S, --do-not-start-view-server   don't start ViewServer                       
  -k, --do-not-ignore-uiautomator-killed don't ignore UiAutomator killed              
  -w, --window=WINDOW              dump WINDOW content (default: -1, all windows)
  -i, --uniqueId                   dump View unique IDs                         
  -x, --position                   dump View positions                          
  -d, --content-description        dump View content descriptions               
  -c, --center                     dump View centers                            
于 2013-09-25T04:58:09.407 回答