title: ClassNotFoundException during Android test instrument
body: <p>I've seen many topics dealing with this error but could not found a working solution. So I'll try to describe the problem completely.</p>
  
  <p>I've got a project and a project test. My project manifest :</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.toto.app"
    android:versionCode="3"
    android:versionName="0.3.1"&gt;
    ...
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      ...
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>And my test project manifest : </p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.toto.app.test"
    android:versionCode="1"
    android:versionName="1.0"&gt;
    &lt;uses-sdk android:minSdkVersion="4" /&gt;
  
    &lt;instrumentation android:targetPackage="com.toto.app" android:name="android.test.InstrumentationTestRunner" /&gt;
  
    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      &lt;uses-library android:name="android.test.runner" /&gt;
    &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Here is the activity i want to test : src/com/toto/app/activity/ListActivity, I've got a LaunchActivity (declared as start activity in manifest) that launch this activity.</p>
  
  <p>And in the test, my ListActivityTest is in the same path (src/com/toto/app/activity). I've also tried with src/com/toto/app/test. The source is :</p>
  
  <pre><code>public class ListActivityTest extends  ActivityInstrumentationTestCase2&lt;LaunchActivity&gt;{
  
    private Solo solo;
  
    public ListActivityTest() {
      super(LaunchActivity.class);
    }
  
    public void setUp() throws Exception {
      solo = new Solo(getInstrumentation(), getActivity());
      solo.wait(2000);
    } 
  }
  </code></pre>
  
  <p>The LaunchActivity seems to be found but when it launch the ListActivity, i've got the error : </p>
  
  <blockquote>
    <p>% adb shell am instrument -w com.toto.app.test/android.test.InstrumentationTestRunner</p>
    
    <p>com.toto.app.activity.ListActivityTest:INSTRUMENTATION_RESULT: shortMsg=java.lang.ClassNotFoundException
    INSTRUMENTATION_RESULT: longMsg=java.lang.ClassNotFoundException: com.toto.app.activity.ListActivity in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.toto.app.test-2.apk:/data/app/com.toto.app-2.apk]</p>
  </blockquote>
  
  <p>I don't understand why one class is found and the other is not... It fails in the same way in Eclipse. I tried to use directly ListActivity in the testcase but same error. How does it build this apk to avoid some class ?</p>
  
  <hr>
  
  <p>This is the full stack when using adb.</p>
  
  <p>The full stack in eclipse logcat : </p>
  
  <pre><code>java.lang.NoClassDefFoundError: com.toto.app.activity.ListActivity
   at com.toto.app.activity.LaunchActivity.onCreate(LaunchActivity.java:19)
   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
   at android.app.ActivityThread.access$1500(ActivityThread.java:132)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:143)
   at android.app.ActivityThread.main(ActivityThread.java:4293)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
   at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.ClassNotFoundException: com.toto.app.activity.ListActivity in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.toto.app.test-2.apk:/data/app/com.toto.app-1.apk]
   at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
   ... 14 more
  </code></pre>