源码如下:
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”是可以正常启动