将4.1.2下正常运行的应用程序放在2.3.4的设备上报错:
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.app.appname/org.app.appname.gui.MainActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
从该错误日志,怀疑两个点
1. Unable to start activity ComponentInfo
网上说是activity路径不正确,建议将相对路径改为绝对路径,比如将 .MainActivity 改为org.app.appname.gui.MainActivity, 改后无效。
2. 第二个点:You must use Theme.Sherlock.......
经检查确实是Theme没有识别,原来是 res/values/styles.xml 将中定义的name与 AndroidManifiest.xml 中引用的不一致所致,具体为:
在 AndroidManifiest.xml :
android:theme="@style/Theme.NameDiff 但应该是 android:theme="@style/Theme.Name
因为在 res/values/styles.xml的定义如下:
<style name="Theme.Name" parent="Theme.Sherlock">
官方知识点参考: http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
但很奇怪的是,上述错误引用的theme,居然在4.1.2下没有问题。