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.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android平台手机 5大优势和劣势
  2. Unity与Android通信优化方案
  3. Android(安卓)自定义控件之组合控件
  4. Android——Intent在Activity的使用详解-
  5. Glide源码解析篇之框架主体结构(一)
  6. 00003 不思议迷宫.0011.2:Android新版中的
  7. [置顶] 基于Proxy思想的Android插件框架
  8. Android同时按下多个按钮
  9. 第21章 0113-jQuery常用DOM操作与Ajax,学
  10. Android数据库更新onupgrade