MainActivity类型的层次结构不一致 [英] The hierarchy of the type MainActivity is inconsistent

查看:209
本文介绍了MainActivity类型的层次结构不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过eclipse使用MainActivity创建了一个新的Android项目。
我将ActionBarSherlock添加到项目中(属性> Android,然后单击添加)。
然后,当我用 extends SherlockFragmentActivity替换 extends Activity时,出现编译错误 MainActivity类型的层次结构不一致。

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还尝试创建一个没有Activity的项目,然后创建一个继承自SherlockFragmentActivity的类 MainActivity,没有编译时错误,但是运行时错误为 ClassNotfoundException:com.NadavLitvak.nadavfragmentdemo.MainActivity。

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"

推荐答案

您的项目还应该引用android-support-v4.jar(包含在ABS的libs文件夹中。) > Java Build Path-> Add JARs ...,然后从ActionBarSherlock-> libs中选择该jar

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

这篇关于MainActivity类型的层次结构不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆