How to fix INJECT_EVENT permission exception when sending touches to an ActivityInstrumentationTestCase2 test
问题 Although there are many examples showing that something like this should work, the following code fails. This code lives in a test project that is associated with the real project. public class MyTest extends ActivityInstrumentationTestCase2<MyActivity> { public MyTest(String name) { super("com.mypackage.activities", MyActivity.class); setName(name); } public void testTap() throws Throwable { //Required by MotionEvent.obtain according to JavaDocs long downTime = SystemClock.uptimeMillis();