title: Android: ClassNotFoundException when running ActionBarSherlock-Plugin-Maps
body: <p>I am trying to setup an example project that uses Jake Wharton's <a href="https://github.com/JakeWharton/ActionBarSherlock" rel="nofollow noreferrer">ActionBarSherlock</a> with <a href="https://github.com/JakeWharton/ActionBarSherlock-Plugin-Maps" rel="nofollow noreferrer">ActionBarSherlock-Plugin-Maps</a>. I follow the instructions <a href="https://stackoverflow.com/a/10041252/356895">here</a> and <a href="https://stackoverflow.com/a/11223857/356895">here</a>. I do not necessarily need Fragments. Here is the simple class I created.</p>
  
  <pre><code>package com.example.actionbarsherlock;
  
  import android.os.Bundle;
  import com.actionbarsherlock.app.SherlockMapActivity;
  
  public class MainActivity extends SherlockMapActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      @Override
      protected boolean isRouteDisplayed() {
          return false;
      }
  }
  </code></pre>
  
  <p>Although I tried to follow the exact descriptions I end up with a <code>ClassNotFoundException</code> when I launch the application. Here is the stacktrace.</p>
  
  <pre><code>  Unable to resolve superclass of Lcom/actionbarsherlock/app/SherlockMapActivity; (729)
    Link of class 'Lcom/actionbarsherlock/app/SherlockMapActivity;' failed
    Unable to resolve superclass of Lcom/example/actionbarsherlock/MainActivity; (533)
    Link of class 'Lcom/example/actionbarsherlock/MainActivity;' failed
   D/AndroidRuntime(408): Shutting down VM
    threadid=3: thread exiting with uncaught exception (group=0x4001b188)
    Uncaught handler: thread main exiting due to uncaught exception
  
    java.lang.RuntimeException: Unable to instantiate activity 
      ComponentInfo{com.example.actionbarsherlock/com.example.actionbarsherlock.MainActivity}: 
      java.lang.ClassNotFoundException: com.example.actionbarsherlock.MainActivity
      in loader dalvik.system.PathClassLoader@44e8ca40
  
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
      at android.app.ActivityThread.access$2200(ActivityThread.java:119)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:123)
      at android.app.ActivityThread.main(ActivityThread.java:4363)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:521)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
      at dalvik.system.NativeStart.main(Native Method)
  
    Caused by: java.lang.ClassNotFoundException: com.example.actionbarsherlock.MainActivity 
      in loader dalvik.system.PathClassLoader@44e8ca40
  
      at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
      at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
      ... 11 more
    threadid=7: reacting to signal 3
    Unable to open stack trace file '/data/anr/traces.txt': Permission denied
  </code></pre>
  
  <p>I tested the library before and created a subclass of <code>SherlockActivity</code> which worked fine. While doing so, I noticed that the same <code>ClassNotFoundException</code> occurs when I forget to configure the <code>android:theme</code> setting in <code>AndroidManifest.xml</code>. Here is the file for both (<code>SherlockActivity</code> and <code>SherlockMapActivity</code>) example projects, just in case:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.actionbarsherlock"
      android:versionCode="1"
      android:versionName="1.0" &gt;
      &lt;uses-sdk
          android:minSdkVersion="7"
          android:targetSdkVersion="15" /&gt;
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:theme="@style/Theme.Sherlock"
              android:name=".MainActivity"
              android:label="@string/title_activity_main" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt; 
  </code></pre>
  
  <hr>
  
  <p><strong>Update:</strong>  </p>
  
  <p>After adding the <code>uses-library</code> setting as suggested by Raghav Sood and M Mohsin Naeem I run into the following message.</p>
  
  <pre><code>Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
  </code></pre>
  
  <p>Here is a screenshot of my projects' setup.</p>
  
  <p><img src="https://i.stack.imgur.com/p6Eox.png" alt="Package Explorer"></p>
  
  <hr>
  
  <p><strong>Edit:</strong>  </p>
  
  <p>Maybe the <code>.classpath</code> file of my <em>actionbarsherlocktest</em>  project helps ...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;classpath&gt;
      &lt;classpathentry kind="src" path="src"/&gt;
      &lt;classpathentry kind="src" path="gen"/&gt;
      &lt;classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/&gt;
      &lt;classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/&gt;
      &lt;classpathentry kind="lib" path="libs/actionbarsherlock-plugin-maps-4.1.0.jar"/&gt;
      &lt;classpathentry kind="output" path="bin/classes"/&gt;
  &lt;/classpath&gt;
  </code></pre>
  
  <p>The <code>.classpath</code> file of the <em>library</em> project looks exactly the same.</p>
  
  <hr>
  
  <p><strong>Solution</strong> to the <code>INSTALL_FAILED_MISSING_SHARED_LIBRARY</code> error message.</p>
  
  <p>For some reasons Eclipse always started the emulator that was configured for API level 7 but <strong>without the Google API</strong>. I could not manage to force it to pick the "map-enabled" emulator. After I deleted the "map-less" emulator the application launched successfully. Do you know how this can happen?</p>
  
  <hr>
  
  <p><strong>Summary:</strong></p>
  
  <p>Finally, I got it running. Here are some experiences I like to share.</p>
  
  <ul>
  <li>Download the latest version of <a href="http://actionbarsherlock.com/download.html" rel="nofollow noreferrer">ActionBarSherlock</a> from the website.</li>
  <li>Do <strong>not</strong> clone the <a href="https://github.com/JakeWharton/ActionBarSherlock" rel="nofollow noreferrer">repository</a> in order to checkout the 4.1.0 tag (9598f2b). It did not work for me.</li>
  <li>Setup the ActionBarSherlock library project in Eclipse.</li>
  <li>Update the contained <code>action-support-v4.jar</code> to the latest version.</li>
  <li>Add the <code>actionbarsherlock-plugin-map-x.y.z.jar</code> to the <code>libs</code> folder of the <strong>library</strong> project.</li>
  <li>You do <strong>not</strong> need to add it to the build path of the library project.</li>
  <li>Setup your main project and add the library project as a dependency.</li>
  <li>You do <strong>not</strong> need to add the <code>action-support-v4.jar</code> or the <code>actionbarsherlock-plugin-map-x.y.z.jar</code> to your main project. It is also <strong>not</strong> necessary to add any of the .jar files to the build path of the main project.</li>
  <li>A <a href="https://github.com/JakeWharton/ActionBarSherlock-Plugin-Maps/tree/master/sample" rel="nofollow noreferrer">simple and helpful example</a> to follow is available in the repository.</li>
  </ul>