title: Simple non-API Android JUnit test in Eclipse with android-maven-plugin?
body: <p>I run non-Android JUnit tests from within Eclipse every day. Today I wanted to test some of my Android library classes. Oh, the pain.</p>
  
  <p>I have an Android library project using android-maven-plugin. I have source files in <code>src/main/java</code> and my (new) unit test in <code>src/test/java</code>. My POM has the appropriate JUnit dependencies and android-maven-plugin references.</p>
  
  <p>Sometimes I create an Android <code>Uri</code> instance from a <code>File</code>. Sometimes I have an existing Java <code>URI</code> instance that I've created from a <code>File</code> which I then convert to a <code>Uri</code>. Since I trust neither Java nor Android with files and URIs (don't get me started on how Java mangles UNC paths in URIs, or how Java breaks the <code>equals()</code> contract in URIs), I wanted to create a simple unit test to create a temp file, create <code>Uris</code> from two different approaches, and make sure they come out equal.</p>
  
  <p>So I make a little JUnit unit test like I'm used to, and try to run it in Eclipse using <code>Ctrl+F11</code>. Eclipse asks me if this is an "Android JUnit Test" or a "JUnit Test". Well, Android, obviously. So I choose the first option and get:</p>
  
  <pre><code>[2013-03-23 21:37:10 - mylib] ------------------------------
  [2013-03-23 21:37:10 - mylib] Android Launch!
  [2013-03-23 21:37:10 - mylib] adb is running normally.
  [2013-03-23 21:37:10 - mylib] Could not find mylib.apk!
  </code></pre>
  
  <p>Hmmm... that wasn't very successful. So I delete the run configuration and try just "JUnit Test". Now I get a different dialog, asking me to select my preferred launcher, either "Android JUnit Test Launcher" or "Eclipse JUnit Test Launcher". It doesn't matter which I choose; I get:</p>
  
  <pre><code>Class not found com.example.MyUnitTest
  java.lang.ClassNotFoundException: com.example.MyUnitTest
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>
  
  <p>I've read that with the android-maven-plugin I can run unit tests locally in Eclipse if they just use classes in the Android jar but don't make any API calls, which is what I'm doing here. So how do I pull that off?</p>