问题描述
已经出现:NoClassDefFoundError Android编写ActionBarActivity 和ActionBarActivity在电话捕获错误
我试图使用 ActionBarCompact 在我的项目。我已经把 Android的支持-V7 项目以及它在我的项目罐子下面,并检查来自许多来源的步骤,但还是我无法处理的问题。
I am trying to use ActionBarCompact in my project. I have linked android-support-v7 project as well as its jar in my project following and checking the steps from lots of sources, but still I am unable to deal with the problem.
当我建立我的项目,没有错误,但在运行时异常。不知道为什么没有检测类。请告诉我什么是错的。谢谢你。
When I built my project, there is no error, but there is exception at runtime. Don't know why class is not detected. Please tell me what is wrong. Thanks.
code:
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.widget.ArrayAdapter;
public class mainMenu extends ActionBarActivity implements ActionBar.OnNavigationListener {
ActionBar actionbar;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menutab);
actionbar = getSupportActionBar();
actionbar.setTitle("Menu");
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter.createFromResource(this,R.array.menu_items, R.id.simpleText);
actionbar.setListNavigationCallbacks(mSpinnerAdapter, this);
}
@Override
public boolean onNavigationItemSelected(int arg0, long arg1)//item pos, itemid
{
switch (arg0) {
case 0:
System.out.println("selected: " + arg0);
break;
case 1:
System.out.println("selected: " + arg0);
break;
case 2:
System.out.println("selected: " + arg0);
break;
case 3:
System.out.println("selected: " + arg0);
break;
default:
break;
}
return true;
}
}
------------项目结构和构建路径-----------------
的logcat
推荐答案
试试这个:
-
导入支持库作为一个项目从
SDK /演员/安卓/支持/ V7 / appcompat
。
在你的项目参考库(用于Eclipse,属性 - 机器人 - 添加
)。
Reference library in your project (for Eclipse, "Properties - Android - Add"
).
如果仍然不能解决你的问题,重新启动Eclipse。
If it still doesn't solve your problem, restart eclipse.
那么干净和改造项目
如果问题仍然存在,从您的计算机中删除的支持库,并重新下载它,并按照上述步骤。
If the problem persists, remove the support library from you computer and redownload it and follow above mentioned steps.
这篇关于ActionBarActivity - NoClassDefFoundError的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!