ActionBarSherlock: java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable

こ雲淡風輕ζ 提交于 2019-11-28 08:26:33

I resolved this issue myself by adding ActionBarSherlock to my Eclipse project in a different way.

Instead of copying actionbarsherlock.jar into libs and adding it to the build path, I added it as a referenced project in the Android section of the project properties.

The app now builds and runs correctly on both the emulator and the device.

Sharj

If you get:

 ActionBarSherlock: java.lang.NoClassDefFoundError:
         com.actionbarsherlock.R$styleable 

exception, then you can fix that by adding Sherlock theme in your manifest file.

android:theme="@style/Theme.Sherlock.Light.DarkActionBar"

There's a problem with the latest ADT 21.1 that can cause this error to surface, even if everything else seems correct. You can fix it by downgrading to ADT 21 and the tools r21. Here's a bug report with some more detail:

https://code.google.com/p/android/issues/detail?id=42686

user3146033

Please let your project's package name and the 3rd party lib package name as the same.

e.g. if the 3rd party lib package name is com.actionbarsherlock and your project's package name is com.yourproject it is of course, you will get java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable error.

To use the 3rd party lib and not use reference like Michael Hampton's answer, you should follow the steps:

  1. rename the package name of com.actionbarsherlock to com.yourproject( I assume that the package name of your project is com.yourproject. Click right button of the mouse on your project -> Android Tools-> Rename Application Package)

  2. copy com.actionbarsherlock/bin/xxx.jar to com.yourproject/libs

  3. copy or merge the resource from xxx.jar in the com.actionbarsherlock's res, such as values, anim, drawable and etc.

I have encountered the same problem, and use the method above thought by myself successfully. If there's more problem, please ask more. I hope all guys could settle the same problem.

make sure ActionBarSherlock project \gen folder has R.java file

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