Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The hierarchy of the type MainActivity is inconsistent

I created a new Android project via eclipse, with a MainActivity. I added ActionBarSherlock to the project (Properties > Android and clicked Add). Then, when I replace "extends Activity" with "extends SherlockFragmentActivity" I get a compile error "The hierarchy of the type MainActivity is inconsistent".

I also tried to create a project without an Activity, then created a class "MainActivity" that inherits from SherlockFragmentActivity, and there are no compile time errors, but with a run-time error "ClassNotfoundException: com.NadavLitvak.nadavfragmentdemo.MainActivity"

like image 268
user2329454 Avatar asked Aug 27 '13 07:08

user2329454


2 Answers

Your project should also reference the android-support-v4.jar (which is included in ABS's libs folder.) So, Properties->Java Build Path->Add JARs... and select that jar from ActionBarSherlock->libs

like image 175
Harlo Holmes Avatar answered Nov 07 '22 17:11

Harlo Holmes


Sometimes, when Eclipse gets retarded, it doesnt add the SDK jar in your project (the Android x.y folder missing in project) so then you need to add it Properties > Android > Project Build Target (usually nothing there is ticked)

like image 2
urSus Avatar answered Nov 07 '22 17:11

urSus