【问题标题】:java.lang.NoClassDefFoundError while using SherlockListActivity使用 SherlockListActivity 时出现 java.lang.NoClassDefFoundError
【发布时间】:2014-10-05 17:28:52
【问题描述】:

我正在尝试使用 ActionBarSherlock 库来实现上下文操作栏。 我有一个导航抽屉,我从中导航到另一个包含列表视图的活动。 从 ActionBarActivity 扩展我的活动时,一切正常,但是当我尝试从 SherlockListActivity 扩展时,我得到了“java.lang.NoClassDefFoundError”。

下面是堆栈跟踪:

08-12 17:50:03.563:E/AndroidRuntime(22395):致命异常:主要 08-12 17:50:03.563: E/AndroidRuntime(22395): java.lang.NoClassDefFoundError: com.example.scholar.Assignments 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 com.example.scholar.Schedule.selectItem(Schedule.java:171) 08-12 17:50:03.563: E/AndroidRuntime(22395): at com.example.scholar.Schedule.access$0(Schedule.java:162) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 com.example.scholar.Schedule$DrawerListItemClickListener.onItemClick(Schedule.java:158) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.widget.AdapterView.performItemClick(AdapterView.java:298) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.widget.AbsListView.performItemClick(AbsListView.java:1114) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.widget.AbsListView$PerformClick.run(AbsListView.java:2933) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.widget.AbsListView$1.run(AbsListView.java:3691) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.os.Handler.handleCallback(Handler.java:615) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.os.Handler.dispatchMessage(Handler.java:92) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.os.Looper.loop(Looper.java:153) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 android.app.ActivityThread.main(ActivityThread.java:5086) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 java.lang.reflect.Method.invokeNative(Native Method) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 java.lang.reflect.Method.invoke(Method.java:511) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821) 08-12 17:50:03.563: E/AndroidRuntime(22395): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 08-12 17:50:03.563: E/AndroidRuntime(22395): at dalvik.system.NativeStart.main(Native Method)

而使用列表视图导航到活动的方法是:

私有类 DrawerListItemClickListener 实现 ListView.OnItemClickListener { @覆盖 public void onItemClick(AdapterView parent, View view, int position, 长身份证){ 选择项目(位置); } }

private void selectItem(int position) {

    // just trying things out and they appear to be working
    switch (position) {
    case 0:
        Intent i = new Intent(Schedule.this, Timetable.class);
        startActivity(i);           
        break;
    case 1:
        Intent assignment = new Intent(Schedule.this, Assignments.class);
        startActivity(assignment);          
        break;
    case 2:


    }

    /**
     * Update selected item and title, then close drawer
     */
    mDrawerList.setItemChecked(position, true);
    setTitle(mDrawerListTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

我们将非常感谢您的帮助

【问题讨论】:

    标签: android


    【解决方案1】:

    在此处查看接受的答案:Android java.lang.NoClassDefFoundError

    这很可能与您遇到的错误相同。 Android 在版本 17 中更改了库的位置以及它们在 Android 中的导出方式。

    基本上,您的库需要在“libs”中,如果不在或不能在,则应在 Order 和 Export 中导出。

    在进行与订单和导出相关的任何更改以及移动库后,请务必进行“清理”。

    【讨论】:

      【解决方案2】:

      好吧,它找不到 com.example.scholar.Assignments 类。是你写的吗?它存在于您的项目中吗?

      我很确定它不是任何类型库中的标准类,因为你不应该将东西放在 com.example 中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-29
        • 1970-01-01
        • 2012-09-01
        • 1970-01-01
        • 2019-08-10
        • 2013-10-01
        相关资源
        最近更新 更多