2 wolfmanzyj wolfmanzyj 于 2014.12.03 16:45 提问

在APK中通过adb shell命令启动UIautomator失败

源码如下:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
Button stButton = (Button)findViewById(R.id.start_test);
stButton.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                            // TODO Auto-generated method stub
                            try {
                                    Process pro = Runtime
                                                    .getRuntime()
                                                    .exec("uiautomator runtest TestHiDP.jar -c com.huawei.cases.TestAllCase");
                            } catch (Exception e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                            }
                    }
            });

    }

报错信息为:
12-03 08:17:24.452: E/UiAutomatorTestRunner(6046): java.lang.RuntimeException: Didn't find class "com.huawei.cases.TestAllCase" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/uiautomator.jar", zip file "/data/local/tmp/TestHiDP.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
12-03 08:17:24.452: E/UiAutomatorTestRunner(6046): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.huawei.cases.TestAllCase" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/uiautomator.jar", zip file "/data/local/tmp/TestHiDP.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

那位大神遇到过此类问题吗?还是说是用uiautomator测试只能通过pc端输入命令启动呢?
p.s.我在pc端输入“adb shell uiautomator runtest TestHiDP.jar -c com.huawei.cases.TestAllCase”是可以正常启动

5个回答

DuZiShou
DuZiShou   2015.07.26 02:44

你是想把uiautomator放在安卓工程里面吧,我一直是pc端调试的。我是最近想在ui测试中调用安卓系统服务,你有办法吗??

gzh8579
gzh8579 您好,请问在安卓工程里可以直接调uiautomator一些命令吗,比如dump界面,谢谢~
一年多之前 回复
DuZiShou
DuZiShou   2015.07.26 02:46

adb shell 里面执行的是Llinux shell命令

u011698206
u011698206   2014.12.09 15:09

需要权限
命令/system/bin/uiautomator runtest TestHiDP.jar -c com.huawei.cases.TestAllCase

CodingFarmers
CodingFarmers   2015.05.16 16:03

我这根本就运行不了,找不到jar包 Error: /data/local/tmp/AutoTest.jar does not exist

楼主问题解决没 帮忙解答一下,谢谢!

wowentian
wowentian   2017.03.21 21:52

我这里PC端也运行不了adb shell uiautomator runtest rhb.jar -c com.rhb.auto.test.AutoTestDemo
报错:Didn't find class "com.android.rhb.test.AutoTestDemo" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/uiautomator.jar", zip file "/data/local/tmp/rhb.jar"],nativeLibraryDirectories=[/system/lib64, /vendor/lib64, /system/lib64, /vendor/lib64]]
请问楼主知道如何解决吗?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!