title: Ui Automator 2.0 project in Android Studio
body: <p>I want to set up a project in Android Studio. <strong>However, I don't want an Android App, just the test project.</strong></p>
  
  <p>Following the lastest <a href="https://plus.google.com/+AndroidDevelopers/posts/WCWANrPkRxg">release of UiAutomator</a>, I was trying to set a class extending ActivityInstrumentationTestCase2 and start my tests from there.</p>
  
  <p>However, I've stumbled in one thing: I can't figure out how to create the project without making it an app.</p>
  
  <p>The options for creating a new project are:</p>
  
  <ul>
  <li>Start a new Android Studio Project</li>
  <li>Open existing projects</li>
  <li>Import projects</li>
  </ul>
  
  <p><strong>I did:</strong></p>
  
  <ol>
  <li>Start a new project, give it a name, set minSDK and choose "No activity"</li>
  <li>Open build.gradle (under app) and add the dependencies and instrumentation information mentioned in the end of <a href="http://developer.android.com/tools/testing-support-library/index.html">Testing Support Library</a></li>
  <li>Opened androidTest under src and changed the main file: changed to ActivityInstrumentationTestCase2, added setUp and tearDown; defined RunWith Junit4 (as indicated in <a href="http://developer.android.com/tools/testing-support-library/index.html">Testing Support Library</a>)</li>
  <li>I build the project (build successful) - Press the green arrow next to build in the "action bar"</li>
  </ol>
  
  <p><strong>My problems are:</strong></p>
  
  <ul>
  <li>How do I install this in the device?</li>
  <li>How do I run it in the device?</li>
  <li>Do I need to do anything in the AndroidManifest?</li>
  <li>Am I editing in the right place? Should I do anything under src/main?</li>
  </ul>
  
  <p>I'd appreciate that the install and run instructions would be both for how to do it through Android Studio and using the command line (if you only know one of them post it anyway please).</p>
  
  <p><em>Note: this is the first time I'm using Android Studio</em></p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Right now I can build and run but it tells me I have no tests to run (empty test suite). Here are my graddle and my code.</p>
  
  <p>My build.graddle is as follows:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 22
      buildToolsVersion "21.1.2"
  
      defaultConfig {
          applicationId "androidexp.com.ceninhas"
          minSdkVersion 21
          targetSdkVersion 22
          versionCode 1
          versionName "1.0"
        testInstrumentationRunner="android.support.test.runner.AndroidJUnitRunner"
      }
      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:testing-support-lib:0.1'
      androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'
  }
  </code></pre>
  
  <p>My source code (under src/androidTest/java/package) is:</p>
  
  <pre><code>@RunWith(AndroidJUnit4.class)
  public class ApplicationTest extends ActivityInstrumentationTestCase2&lt;Activity&gt; {
      public final static String ACTIVITY_NAME = "com.calculator.Main";
      public final static Class&lt;?&gt; autActivityClass;
  
      static {
          try {
              autActivityClass = Class.forName(ACTIVITY_NAME);
          } catch (ClassNotFoundException e) {
              throw new RuntimeException(e);
          }
      }
  
      public ApplicationTest(){
          super((Class&lt;Activity&gt;)autActivityClass);
      }
  
      @Before
      public void setUp() throws Exception{
          super.setUp();
          injectInstrumentation(InstrumentationRegistry.getInstrumentation());
      }
  
      @After
      public void tearDown() throws Exception{
          super.tearDown();
      }
  
      @Test
      public void cenas(){
          assertTrue(true);
      }
  }
  </code></pre>
  
  <p>The run log on the console was:</p>
  
  <pre><code>Testing started at 18:06 ...
  Waiting for device.
  Target device: lge-nexus_5-08e506c10ddef123
  Uploading file
      local path: C:\Users\Ines\workspace\Ceninhas\app\build\outputs\apk\app-debug.apk
      remote path: /data/local/tmp/androidexp.com.ceninhas
  No apk changes detected. Skipping file upload, force stopping package instead.
  DEVICE SHELL COMMAND: am force-stop androidexp.com.ceninhas
  Uploading file
      local path: C:\Users\Ines\workspace\Ceninhas\app\build\outputs\apk\app-debug-androidTest-unaligned.apk
      remote path: /data/local/tmp/androidexp.com.ceninhas.test
  No apk changes detected. Skipping file upload, force stopping package instead.
  DEVICE SHELL COMMAND: am force-stop androidexp.com.ceninhas.test
  Running tests
  Test running startedFinish
  Empty test suite.
  </code></pre>
  
  <p>What am I doing wrong?</p>