Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uiAutomator failing on 4.1.2 device

When playing with the Android uiAutomator I've run into an issue when trying to run the tests on a 4.1.2 device. When using the code from the enter link description here an exception is thrown when attempting to scroll the apps tray.

I originally thought it was caused by compiling against api 17 rather than 16 but that doesn't seem to be true. Anyone else encountered this?

Exception raised:

[exec] java.lang.reflect.InvocationTargetException [exec] at java.lang.reflect.Method.invokeNative(Native Method) [exec] at java.lang.reflect.Method.invoke(Method.java:511) [exec] at com.example.runTests(Runner.java:124) [exec] at com.example.testExecutor(Runner.java:60) [exec] at java.lang.reflect.Method.invokeNative(Native Method) [exec] at java.lang.reflect.Method.invoke(Method.java:511) [exec] at junit.framework.TestCase.runTest(TestCase.java:168) [exec] at junit.framework.TestCase.runBare(TestCase.java:134) [exec] at junit.framework.TestResult$1.protect(TestResult.java:115) [exec] at junit.framework.TestResult.runProtected(TestResult.java:133) [exec] at junit.framework.TestResult.run(TestResult.java:118) [exec] at junit.framework.TestCase.run(TestCase.java:124) [exec] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:124) [exec] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:85) [exec] at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:76) [exec] at com.android.commands.uiautomator.Launcher.main(Launcher.java:83) [exec] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) [exec] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235) [exec] at dalvik.system.NativeStart.main(Native Method) [exec] Caused by: java.lang.NoSuchMethodError: com.android.uiautomator.core.UiScrollable.setAsHorizontalList [exec] at com.example.Runner.launchAppFromHomeScreen(Test.java:45) [exec] ... 19 more

like image 205
MrChaz Avatar asked Feb 18 '23 07:02

MrChaz


1 Answers

UIAutomator's codes has changes:

4.1.1 method : public void setAsHorizontalList ()
4.2 method : public UIScrollable setAsHorizontalList ()

It's maybe you are using API-17's UIAutomator to build the tests but running on a API-16 device. Try using the corresponding UIAutomator.jar

like image 89
Aria4Larry Avatar answered Feb 27 '23 23:02

Aria4Larry