知道我为什么会有这样的例外。它应该是非常直截了当和简单。它编译时没有任何错误或警告。在运行时,它会引发异常。
Instrumentation im = new Instrumentation();
UiAutomation myVar = im.getUiAutomation();
myVar.injectInputEvent(evntDown,false);这是个例外。
01-26 11:59:17.344 17742-17742/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.app.Instrumentation.getUiAutomation
at com.infostretch.automateme.MainActivity$1.onClick(MainActivity.java:51)
at android.view.View.performClick(View.java:4202)
at android.view.View$PerformClick.run(View.java:17340)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)发布于 2014-01-26 17:23:23
UIAutomation包括在API 18中。当您尝试访问/使用当前运行应用程序的OS/API版本不支持的类/方法时,会发生NoSuchMethod异常。
https://stackoverflow.com/questions/21366630
复制相似问题