title: AndroidRuntime java.lang.NoClassDefFoundError my.package.CustomActionBarDrawerToggle
body: <p>I am using Eclipse as IDE. 
  Android SDK Platform-tools 21 ( latest )</p>
  
  <p>With the wizard I have added a "Navigation Drawer Activity". Next-> Next->... Finish.</p>
  
  <p>Then I saw there are deprecated methods, I have checked already here and some are because is deprecated in API version 21 others are because the v4 is replaced with v7.</p>
  
  <pre><code>   &lt;uses-sdk
          android:minSdkVersion="15"
          android:targetSdkVersion="21" /&gt;
  </code></pre>
  
  <p>I want to support the v15, without deprecations, and compile it with 5.0 ( I am not sure if that is a correct method or not)</p>
  
  <p>I have changed the imports to:</p>
  
  <pre><code>import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.widget.DrawerLayout;
  </code></pre>
  
  <p>as how it is suggested in other posts.</p>
  
  <p>Also in <code>FragmentActivity</code> the <code>Activity</code>:</p>
  
  <pre><code>public class HomeActivity extends FragmentActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks 
  </code></pre>
  
  <p>Also changed: </p>
  
  <pre><code>@Override
  public void onNavigationDrawerItemSelected(int position) {
      // update the main content by replacing fragments
  
      FragmentManager fragmentManager = getSupportFragmentManager();
      fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
  }
  </code></pre>
  
  <p>And added the ignore:</p>
  
  <pre><code>// http://stackoverflow.com/a/27626971 : ignore, because it is not only for android 5.0
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
  </code></pre>
  
  <p>This class has no other changes versus the generated.</p>
  
  <p>The NavigationDrawerFragment has a few changes. The imports has changed to above.</p>
  
  <p>The <code>setUp()</code> declares an anonymous class that has been extracted and modified according to other SO post. </p>
  
  <p>At this line it is the exception:</p>
  
  <pre><code>mDrawerToggle = new CustomActionBarDrawerToggle(this, getActivity(), mDrawerLayout);
  </code></pre>
  
  <p>Here is the class:</p>
  
  <pre><code>import android.app.Activity;
  import android.content.SharedPreferences;
  import android.preference.PreferenceManager;
  import android.support.v4.widget.DrawerLayout;
  import android.support.v7.app.ActionBarDrawerToggle;
  import android.view.View;
  
  public class CustomActionBarDrawerToggle extends ActionBarDrawerToggle {
  
      private NavigationDrawerFragment navigationDrawerFragment;
  
      public CustomActionBarDrawerToggle(NavigationDrawerFragment navigationDrawerFragment, Activity mActivity, DrawerLayout mDrawerLayout) {
          super(mActivity, mDrawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
          this.navigationDrawerFragment = navigationDrawerFragment;
      }
  
      @Override
      public void onDrawerClosed(View drawerView) {
          super.onDrawerClosed(drawerView);
          if (!navigationDrawerFragment.isAdded()) {
              return;
          }
  
          navigationDrawerFragment.getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
      }
  
      @Override
      public void onDrawerOpened(View drawerView) {
          super.onDrawerOpened(drawerView);
          if (!navigationDrawerFragment.isAdded()) {
              return;
          }
  
          if (!navigationDrawerFragment.isUserLearnedDrawer()) {
              // The user manually opened the drawer; store this flag to prevent auto-showing
              // the navigation drawer automatically in the future.
              navigationDrawerFragment.setUserLearnedDrawer(true);
              SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(navigationDrawerFragment.getActivity());
              sp.edit().putBoolean(NavigationDrawerFragment.PREF_USER_LEARNED_DRAWER, true).apply();
          }
  
          navigationDrawerFragment.getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
      }
  
  }
  </code></pre>
  
  <p>With File Import  I have imported from the SDK the <code>android-support-v7-appcompat</code> Marked as library and it compiles.</p>
  
  <p>I have set the dependency to this project and marked at Order And Export.</p>
  
  <p>I have copied the <code>android-support-v4.jar</code> from appcompat to my project to be the same version. Still the same exception at runtime.</p>
  
  <p>I have added the <code>android-support-v7-appcompat.jar</code> from .bin directory ( the compiled one) to my project libs. Still the same error at runtime.</p>
  
  <p>Before extracting the anonymous class the message it was NoClassDefFoundError android.support.v7.app.ActionBarDrawerToggle as  I remember - the parent class.</p>
  
  <p>Yesterday wasted all day to figure out and ended in deleting and use deprecated methods, but  I would like to have a non deprecated version - if is possible. </p>
  
  <p>Pls come with suggestion, which I didn't made already!</p>