配置开源项目 SlidingMenu 的问题

 

最近想研究一下开源项目 SlidingMenu,单是配置项目就花了好长的时间,断断续续的尝试,终于配置成功了,写下来和大家分享一下经验。

Step 1:导入依赖的项目和例子

打开项目 File -> Import -> Android -> Existing Android Code Into Workspace, 找到相应的目录,引入相应的工程

如果不知道如何将项目引入当前工程请参考链接1

Step 2: 解决依赖的项目存在的问题

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

    Fix: 检查当前是否有相应版本的android avd的支持

  • 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: 将最低版本改为较新的版本

Step 3: 解决 SlidingMenu 的例子项目问题

  • 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: 将几个替换成同一个版本的jar 包, Clean 一下项目

  • 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: 打开 SlidingMenu library 项目的SlidingFragmentActivity.java  在头部添加引用:

    import com.actionbarsherlock.app.SherlockFragmentActivity;

    将:

    public class SlidingFragmentActivity extends FragmentActivity implements SlidingActivityBase {

    改为:

    public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {

    如果错误仍存在就clean一下工程

Tip:保证你的例子项目中引入了ActionBarSherlock和SlidingMenu类库

参考:

http://stackoverflow.com/questions/14057367/exact-procedure-to-add-jfeinstein10-slidingmenu-in-android-project/14118683#14118683

http://boroniatechnologies.com/installing-slidingmenu-android-library-and-example/

 


原文地址:https://www.cnblogs.com/keanuyaoo/p/3299544.html