The hierarchy of type MainActivity is incompatible

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

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

+7
actionbarsherlock android-fragmentactivity
source share
2 answers

Your project should also have a link to android-support-v4.jar (which is included in the ABS libs folder.) So Properties-> Java Build Path-> Add JARs ... and select this jar from ActionBarSherlock-> libs

+16
source share

Sometimes, when Eclipse gets late, it does not add the SDK jar to your project (there is no project in the Android xy folder), so you need to add it. Properties> Android> Project Build Target (usually nothing is marked)

+2
source share