getUiDevice().pressHome();
new UiObject(new UiSelector().description("Apps")).click();
new UiObject(new UiSelector().text("Apps")).click();
new UiScrollable(new UiSelector().scrollable(true)).setAsHorizontalList().scrollIntoView(new UiSelector().text("Settings"));
new UiObject(new UiSelector().text("Settings")).click();
new UiScrollable(new UiSelector().scrollable(true)).scrollTextIntoView("Accessibility");
new UiObject(new UiSelector().text("Accessibility")).click();
最后一行代码在我的 Nexus 4 上导致以下错误,我试图用谷歌搜索它,但找不到任何相关信息,所以有人可以帮助解释为什么会发生错误吗?
10-23 13:43:16.466: E/AndroidRuntime(7995): FATAL EXCEPTION: main
10-23 13:43:16.466: E/AndroidRuntime(7995): java.lang.RuntimeException: Unable to resume activity {com.android.settings/com.android.settings.SubSettings}: java.lang.NullPointerException
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2790)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.os.Handler.dispatchMessage(Handler.java:99)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.os.Looper.loop(Looper.java:137)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-23 13:43:16.466: E/AndroidRuntime(7995): at java.lang.reflect.Method.invokeNative(Native Method)
10-23 13:43:16.466: E/AndroidRuntime(7995): at java.lang.reflect.Method.invoke(Method.java:525)
10-23 13:43:16.466: E/AndroidRuntime(7995): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-23 13:43:16.466: E/AndroidRuntime(7995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-23 13:43:16.466: E/AndroidRuntime(7995): at dalvik.system.NativeStart.main(Native Method)
10-23 13:43:16.466: E/AndroidRuntime(7995): Caused by: java.lang.NullPointerException
10-23 13:43:16.466: E/AndroidRuntime(7995): at com.android.settings.AccessibilitySettings.loadInstalledServices(AccessibilitySettings.java:586)
10-23 13:43:16.466: E/AndroidRuntime(7995): at com.android.settings.AccessibilitySettings.onResume(AccessibilitySettings.java:196)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.Fragment.performResume(Fragment.java:1738)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1039)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:1850)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.Activity.performResume(Activity.java:5221)
10-23 13:43:16.466: E/AndroidRuntime(7995): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2780)
10-23 13:43:16.466: E/AndroidRuntime(7995): ... 12 more