title: UiDevice.getInstance(getInstrumentation()) Crashes (as Null object reference) when Launching the Instrumentation using startInstrumentation()
body: <p>Android SDK : 22 (L)
  UiAutomator Version : 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'</p>
  
  <p>On a Button Click I am trying to Access Instrumentation from an Android Application using </p>
  
  <pre><code>Boolean start = false;
  start = startInstrumentation(new ComponentName("com.automation.vzw.sanity.test", "android.test.InstrumentationTestRunner"), null, null);
    System.out.println("value of start is " +start);
  </code></pre>
  
  <p>Value of the start shows "true" which indicates it was launched</p>
  
  <p>Problem is : once the Instrumentation starts and setUp() is called , when the below gets executed , there is a Crash </p>
  
  <pre><code>public class ApplicationTest extends InstrumentationTestCase {
  
   public void setUp() {
                UiDevice testDevice = UiDevice.getInstance(getInstrumentation());
               }
  
   public void testCase1(){
  
          System.out.println("In testcase1");
  
  }
  
  }
  </code></pre>
  
  <p>Crash Details : </p>
  
  <pre><code>/TestRunner(11209): started: testCase1(com.automation.vzw.sanity.ApplicationTest)
  
  I/TestRunner(11209): failed: testCase1(com.automation.vzw.sanity.ApplicationTest)
  
  I/TestRunner(11209): ----- begin exception -----
  
  I/TestRunner(11209): 
  
  I/TestRunner(11209):   java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.UiAutomation.setOnAccessibilityEventListener(android.app.UiAutomation$OnAccessibilityEventListener)' on a null object reference
  
  I/TestRunner(11209):    at android.support.test.uiautomator.UiAutomatorBridge.setOnAccessibilityEventListener(UiAutomatorBridge.java:78)
  
  I/TestRunner(11209):    at android.support.test.uiautomator.QueryController.&lt;init&gt;(QueryController.java:58)
  
  I/TestRunner(11209):    at android.support.test.uiautomator.UiAutomatorBridge.&lt;init&gt;(UiAutomatorBridge.java:66)
  
  I/TestRunner(11209):    at android.support.test.uiautomator.InstrumentationUiAutomatorBridge.&lt;init&gt;(InstrumentationUiAutomatorBridge.java:35)
  
  I/TestRunner(11209):    at android.support.test.uiautomator.UiDevice.&lt;init&gt;(UiDevice.java:103)
  
  I/TestRunner(11209):    at android.support.test.uiautomator.UiDevice.getInstance(UiDevice.java:263)
  
  I/TestRunner(11209):    at com.automation.vzw.sanity.ApplicationTest.setUp(ApplicationTest.java:103)
  
  I/TestRunner(11209):    at junit.framework.TestCase.runBare(TestCase.java:132)
  
  I/TestRunner(11209):    at junit.framework.TestResult$1.protect(TestResult.java:115)
  
  I/TestRunner(11209):    at junit.framework.TestResult.runProtected(TestResult.java:133)
  
  I/TestRunner(11209):    at junit.framework.TestResult.run(TestResult.java:118)
  
  I/TestRunner(11209):    at junit.framework.TestCase.run(TestCase.java:124)
  
  I/TestRunner(11209):    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
  
  I/TestRunner(11209):    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
  
  I/TestRunner(11209):    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
  
  I/TestRunner(11209):    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1944)
  
  I/TestRunner(11209): ----- end exception -----
  
  I/TestRunner(11209): finished: testCase1(com.automation.vzw.sanity.ApplicationTest)
  
  I/ActivityManager(30686): Force stopping com.automation.vzw.sanity appid=10175 user=0: finished inst
  
  I/ActivityManager(30686): Killing 11209:com.automation.vzw.sanity/u0a175 (adj 0): stop com.automation.vzw.sanity
  
  I/ServiceManager(31912): Waiting for service SurfaceFlinger...
  
  W/ActivityManager(30686): Spurious death for ProcessRecord{2a8ec647 11209:com.automation.vzw.sanity/u0a175}, curProc for 11209: null
  </code></pre>
  
  <p><strong>Note: when executed from command line there is no problem works well (am instrument -w com.automation.vzw.sanity.test/android.test.InstrumentationTestRunner)</strong></p>
  
  <p>Please help to overcome this</p>
  
  <p>Thanks</p>