如果你的eclipse没有提示代码错误,估计是ant编译时,没有把uiautomator.jar打进去
你要判断下eclipse使用的android环境中的uiautomator.jar,还是手动添加到工程的uiautomator.jar
如果是使用的android环境中的uiautomator.jar,你就要检查安卓环境变量是否正确,eclipse使用的sdk版本是否正确
如果是手动添加uiautomator.jar到工程中,你就要修改build.xml了,把下面添加进去
source="${java.source}" target="${java.target}"
debug="true" extdirs="${external-lib-ospath}" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
fork="${need.javac.fork}">
output="${intermediate.dex.file}"
nolocals="@{nolocals}"
verbose="${verbose}">
上面的xml目的就是ant执行compile和-dex任务时,使用工程的三方jar包