从活动启动检测时出现空指针异常错误

我正在从活动中触发android测试;

        final List<InstrumentationInfo> list =
                getPackageManager().queryInstrumentation(packageName, 0);
        if ( list.isEmpty() ) {
            Toast.makeText(this, "Cannot find instrumentation for " + packageName,
                    Toast.LENGTH_SHORT).show();
            return;
        }
        final InstrumentationInfo instrumentationInfo = list.get(0);

        final ComponentName componentName =
                new ComponentName(instrumentationInfo.packageName,
                        instrumentationInfo.name);

        Intent mIntent = new Intent(this, MainActivity.class);
        mIntent.putExtra("Context", this.getApplicationContext().toString());

        Bundle arguments = new Bundle();
        arguments.putString("package", "com.glu.whymeapplication");


        if ( !startInstrumentation(componentName, null, arguments) ) {
            Toast.makeText(this, "Cannot run instrumentation for " + packageName,
                    Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, "Successfully executed instrumentation for " + packageName,
                    Toast.LENGTH_SHORT).show();
        }

执行时,我得到了错误; java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void android.app.UiAutomation.setOnAccessibilityEventListener(android.app.UiAutomation $ OnAccessibilityEventListener)' 有谁知道如何解决这个问题???

评论