在使用 UiautomatorTestcase 类捕获我的主要活动的屏幕截图时,我面临以下异常。
我正在使用的示例代码
public class MyActivityTest extends UiAutomatorTestCase {
public UiautomatorAdaptxt() {
// TODO Auto-generated constructor stub
}
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
super.setUp();
}
public void testOpenMainActivity() throws UiObjectNotFoundException {
-->Here I use the code to open my Activity<--
getUiDevice().takeScreenshot(storePath);
}
}
我面临的例外是
java.lang.NoSuchMethodError:com.android.uiautomator.core.UiDevice.takeScreenshot at .testOpenMainActivity(MyActivityTest .java:31) at java.lang.reflect.Method.invokeNative(Native Method) at com.android.uiautomator.testrunner。 UiAutomatorTestRunner.start(UiAutomatorTestRunner.java :124) at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:8 5) at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:76) at com.android.commands.uiautomator.Launcher.main(Launcher.java:83) 在 com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) 在 com.android.internal.os.RuntimeInit.main(RuntimeInit.java :235) 在 dalvik.system.NativeStart.main(Native Method)