NoClassDefFoundError Android with ActionBarActivity

﹥>﹥吖頭↗ 提交于 2019-12-02 03:51:13

问题


I currently have an ActionBarActivity which always returns a NoClassDefFoundError. I've read that it might be a problem with the ADT but I cannot be sure, hence my question. I've imported the ActionBar sample from the Android samples under

android-sdk\samples\android-14\ActionBarCompat

I've labelled the ActionBarCompat project as a library under Project -> Properties but I'm still getting the error.

To reiterator:

public class SearchActivity extends ActionBarActivity { // Doesn't work, yields exception

public class SearchActivity extends Activity { // Works perfectly

Has anyone else experienced a similar error and perhaps found a solution?

Thanks in advance.


回答1:


http://developer.android.com/tools/support-library/setup.html The "Adding libraries with resources" section may help since this is not in the most common v4 support library

include only android-support-v4.jar is not enough




回答2:


Ended up using ActionBarSherlock instead and added a project reference under Project Properties as well as in the Build Path. Seems to have fixed all errors relating to my question.




回答3:


Just this morning, Google released Android 4.3. They also updated its support library that allows ActionBar to be implemented on lower versions. Just have to extend ActionBarActivity. See guidelines here and tutorial here.




回答4:


I've got the same problem. I solved it getting the android-support-v7-appcompat.jar library.

See here http://developer.android.com/tools/support-library/setup.html#using-apis how to install it.

I recommend focus on "Adding libraries without resources" instead "Adding libraries with resources" for the sake of simplicity.

When you do it, don't forget to import the this library into your Activity Java source. You can do it declaring import android.support.v7.app.ActionBarActivity;




回答5:


I solved this problem like so, when you add the library make sure it does not have the android-support-v4 along with it (in libs folder of the library un-check android dependencies and android-support-v4), that's in the case where your project already have the android-support-v4, that's why you can't find class ActionBarActivity




回答6:


This Link may help you. This library is located in the /extras/android/support/v7/appcompat/ directory. Include in eclipse and add as library. This will solve your problem.



来源:https://stackoverflow.com/questions/12662673/noclassdeffounderror-android-with-actionbaractivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!