源码如下:
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”是可以正常启动
需要权限
命令/system/bin/uiautomator runtest TestHiDP.jar -c com.huawei.cases.TestAllCase
我这根本就运行不了,找不到jar包 Error: /data/local/tmp/AutoTest.jar does not exist
楼主问题解决没 帮忙解答一下,谢谢!
你是想把uiautomator放在安卓工程里面吧,我一直是pc端调试的。我是最近想在ui测试中调用安卓系统服务,你有办法吗??
adb shell 里面执行的是Llinux shell命令
我这里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]]
请问楼主知道如何解决吗?