uiautomator 自动化测试,使用uiobject 对象,ant编译报错,怎么解决??求大神

2026年09月23日 05:01
有1个网友回答
网友(1):

如果你的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包