Actionbarsherlock noClassDefFoundError com.actionb

2019-05-15 06:51发布

问题:

I am migrating my code to use Actionbarsherlock. I have made all the code adaption that I need to and my project compiles fine with no errors, however I get the following exception:

java.lang.NoClassDefFoundError: com.actionbarsherlock.R$Styleable at com.actionbarsherlock.internal.ActionbarSherlockCompat.generateLayout(ActionbarSherlockCompat.java 1002)

I am using version 4.1 of actionbar sherlock. I get this exception when the first activity starts every time. I have cleaned and rebuild the project, checked my buildpaths, and can not find what is missing. Anyhelp would be great!!!

回答1:

If you’re using the Eclipse Development Environment with the ADT plugin version 0.9.7 or greater you can include ActionBarSherlock as a library project. Create a new Android project in Eclipse using the library/ folder as the existing source. Then, in your project properties, add the created project under the ‘Libraries’ section of the ‘Android’ category.

The rest of the user manual is here.



回答2:

I got this Error to when using the SDK Tools Preview 21 and the ADT preview.

Occurred when inflating menu items with actionbarsherlock using. getSupportMenuInflater().inflate(R.menu.search, menu);

Reverting to SDK Tools 20 fixed it.

logcat error:

11-03 09:29:44.738: E/AndroidRuntime(14878): java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable
11-03 09:29:44.738: E/AndroidRuntime(14878):    at com.actionbarsherlock.view.MenuInflater$MenuState.readItem(MenuInflater.java:343)
11-03 09:29:44.738: E/AndroidRuntime(14878):    at com.actionbarsherlock.view.MenuInflater.parseMenu(MenuInflater.java:162)
11-03 09:29:44.738: E/AndroidRuntime(14878):    at com.actionbarsherlock.view.MenuInflater.inflate(MenuInflater.java:112)


回答3:

Had the same issue. updating to the latest version of actionbarsherlock and doing a clean all helped me.



回答4:

This issue may caused by ADT version,I solved this issue by using adt-bundle-windows-x86.



回答5:

This happened to me after signing the application. The signed apk was returning the above error, while before signing everything worked well. Closing that damn eclipse and starting it again (built in restart option did not work) did the trick for me.