How to build android UIAutomator project?

时间:2015-07-31 19:33:57

标签: java android compilation uiautomator android-uiautomator

Is there any way how to build UiAutomator (https://android.googlesource.com/platform/frameworks/testing/+/jb-mr2-release/uiautomator/cmds/uiautomator/) module? UiAutomator has command called dump, which you can execute on device / emulator shell by calling uiautomator dump and this will generate a xml file with UI hierarchy. But what a problem is that if special character came into play (visible on screen) likey smileys which Im guessing are UTF-16 chars the xml generator behind the UIAutomator fails (this is actually known issue) with exception of IllegalCharacter

https://android.googlesource.com/platform/libcore/+/10d1f630d8df0064ed966193fa8c9d10a96a8321/xml/src/main/java/org/kxml2/io/KXmlSerializer.java line 130

Im not really experienced in java programming, but I'm guessing I should be able to update java code to avoid this issue. But the problem is Im not really able to compile this module into jar file.

Can anyone help me with this?

1 个答案:

答案 0 :(得分:3)

是的,您可能需要签出AOSP项目并构建此特定模块。方法如下:

  1. Set up your environment(我希望您使用的是基于UNIX的计算机)
  2. Download AOSP source
  3. Build AOSP
  4. 现在,诀窍是将UiAutomator构建为框架(AOSP)模块。为此,请运行:

    make uiautomator
    

    确保设置环境变量(source build / envsetup.sh)并预先选择目标和组合(午餐)。

    NB:每个AOSP模块都包含一个Android.mk makefile,其中指定了模块名称。在你的例子中,我只是看看Android.mk并发现了这个:

    LOCAL_MODULE := uiautomator