Installing SlidingMenu Android library and example


SlidingMenu is a helpful Android library for developers. It creates a side navigation like the Facebook app but it is not easy to setup the library nor the example. Here you will find the steps to make the library and example free of errors and ready to use.

Step 1: Import the library and example
Download the library as well as the app on GitHub (https://github.com/jfeinstein10/slidingmenu). Then, unzip the file and create a new project in Eclipse. Select Android Project from Existing Code and click Next. Click Browse and choose the folder where you unzip the SlidingMenu library. Check Copy projects into workspace and click Finish. You have imported the library and example but you have an X icon next to the SlidingMenu library project and an exclamation mark icon next to the example project.

Step 2: Fix errors in SlidingMenu library project
The following list describes the possible errors that you might have after importing the library:

  • Console error: Unable to resolve target ‘Google Inc.:Google APIs:16.

    Fix: Go to Properties for library and check Google APIs for the desired platform.

  • List of errors: ACTION_POINTER_INDEX_MASK cannot be resolved android.
    HONEYCOMB cannot be resolved or is not a field
    LAYER_TYPE_HARDWARE cannot be resolved or is not a field
    LAYER_TYPE_NONE cannot be resolved or is not a field
    MATCH_PARENT cannot be resolved or is not a field
    The method getLayerType() is undefined for the type View
    The method setLayerType(int, null) is undefined for the type View

    Fix: Change the min sdk version of the library manifest with a recent one.

Step 3: Fix errors in SlidingMenu example project
After importing the example, these are the possible errors:

  • Console error: Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are identical (check is based on SHA-1 only at this time). Jar mismatch! Fix your dependencies

    Fix: Identify which project has the latest version and copy it on the old version. Clean the projects and restart eclipse if the error messages still appear in the console tab.

  • List of errors: The method getSupportActionBar() is undefined for the type BaseActivity
    The method getSupportMenuInflater() is undefined for the type BaseActivity
    The method onCreateOptionsMenu(Menu) of type BaseActivity must override or implement a supertype method
    The method onOptionsItemSelected(MenuItem) in the type Activity is not applicable for the arguments
    The method onOptionsItemSelected(MenuItem) of type BaseActivity must override or implement a supertype method
    The method onOptionsItemSelected(MenuItem) of type ResponsiveUIActivity must override or implement a supertype method

    Fix: Open SlidingFragmentActivity class of the SlidingMenu library project and add the following code before declaring the class:

    import com.actionbarsherlock.app.SherlockFragmentActivity;

    Then, replace the class declaration:

    public class SlidingFragmentActivity extends FragmentActivity implements SlidingActivityBase {

    with:

    public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {

    Clean and build the project if the error messages still appear.

Tip:Make sure that your example project is referencing the ActionBarSherlock and SlidingMenu library contained in your workspace.

Summary: Although SlidingMenu is a helpful Open Source library for Android developers, setting up the library and the example are not easy to do. So, this article intends to save you time on researching each error that you get after importing the library and example files.

Comments

    Sam

    Thanks alot. You’re a life saver. Been struggling for weeks.

      lebasca

      You’re welcome! I’m glad that it was helpful for you.

    Tyler

    Just wanted to say thanks. I’m new to andriod development, and this was quite helpful!

    Alex

    thanks you!

    Muazz

    Thanks for sharing. I am still having issue with HONEYCOMB, LAYER_TYPE_HARDWARE …..

    I changed the manifest file to android:minSdkVersion=”8″
    android:targetSdkVersion=”17″

    and no change. Any idea? I can get rid of it if I set build target to 4.1 but if I do that then I start getting this error: Unable to resolve target ‘Google Inc.:Google APIs:16.

    Help!

      lebasca

      Hi there, change your Project build target to Google API’s 4.2.

        Muazz

        Thank you sir. 4.2 solved my issue. Thanks for sharing and quick response.

    Rene

    Hi
    I am still having a issue with this:
    Description Resource Path Location Type
    error: Error retrieving parent for item: No resource found that matches the given name ‘Theme.Sherlock.Light.DarkActionBar’. styles.xml /ExampleListActivity/res/values line 4 Android AAPT Problem

    @drawable/new_indicator

      lebasca

      Hi Rene, make sure you added the Sherlock library to the SlidingMenu library.

    RCEN

    I have no words for my gratitude.
    Thank you for your help!!

    Instalar BIBLIOTECA SlidingMenu y el ejemplo, « El Pensadero de Isma
    Ahmed

    Time you have taken to do this wasn’t wasted, you have helped some many fellow programmers.
    Thanks alot

About Boronia Technologies

Boronia Technologies is the business name of Catherine Lebastard, an IT professional with extensive experience in web development and database administration. Catherine chose the name of Boronia as she likes flowers and purple color. The logo of her business is inspired on Boronia flower plus digital elements incorated inside the flower.


Why you should use my services?

Because I can guide you to the right path and provide you what you are looking for at the right price according to your budget. Also, I am able to develop or debug an application with any programming language that you request because I have the ability to learn at extremely fast pace and adapt easily to progress in technology.