title: UiAutomator 2.0 test from command line
body: <p>I'm trying to use Android UIAutomator for some simple tests, I'm aware of that it needs to be built by Gradle since UIAutomator 2.0, I can run my simple test which only presses home button via Android Studio or command line by "gradlew.bat cC", I was wondering how I can run it with adb command? </p>
  
  <p>I tried </p>
  
  <pre><code>adb shell am instrument -w test.simple.uiatest/android.test.InstrumentationTestRunner
  </code></pre>
  
  <p>as suggested <a href="http://developer.android.com/tools/testing/testing_otheride.html#RunTestsDevice" rel="nofollow">here</a> , but I get</p>
  
  <pre><code>INSTRUMENTATION_STATUS: id=ActivityManagerService
  INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{test.simple.uiatest/android.test.InstrumentationTestRunner}
  INSTRUMENTATION_STATUS_CODE: -1
  android.util.AndroidException: INSTRUMENTATION_FAILED: test.simple.uiatest/android.test.InstrumentationTestRunner
      at com.android.commands.am.Am.runInstrument(Am.java:951)
      at com.android.commands.am.Am.onRun(Am.java:316)
      at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
      at com.android.commands.am.Am.main(Am.java:99)
      at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
      at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:250)
  </code></pre>
  
  <p>Below are my code snippet and build.gradle, what am I doing wrong?</p>
  
  <pre><code>package test.simple.uiatest;
  
  import android.support.test.uiautomator.UiDevice;
  import android.test.InstrumentationTestCase;
  
  public class ApplicationTest extends InstrumentationTestCase {
      private UiDevice theDevice;
  
      @Override
      public void setUp() throws Exception {
          super.setUp();
          theDevice = UiDevice.getInstance(getInstrumentation());
  
          theDevice.pressHome();
      }
  
      public void testName() throws Exception {
          theDevice.pressHome();
      }
  }
  </code></pre>
  
  <p>build.gradle</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 22
      buildToolsVersion "23.0.0 rc2"
  
      defaultConfig {
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          applicationId "test.simple.uiatest"
          minSdkVersion 21
          targetSdkVersion 22
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  
      packagingOptions {
          exclude 'LICENSE.txt'
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      androidTestCompile 'com.android.support.test:runner:0.2'
      androidTestCompile 'com.android.support.test:rules:0.2'
      androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
  }
  </code></pre>