6

我已经在 google play 上进行了更新,并看到了这个错误:

java.lang.RuntimeException: Unable to start activity 

ComponentInfo{com.jim2/com.jim2.SettingWidgetActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1007)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:919)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:853)
at com.actionbarsherlock.app.SherlockFragmentActivity.setContentView(SherlockFragmentActivity.java:251)
at com.jim2.SettingWidgetActivity.onCreate(SettingWidgetActivity.java:37)
at android.app.Activity.performCreate(Activity.java:4397)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
... 11 more

我不明白为什么会出现此错误,因为它在我的设备上完美运行

有人有想法吗?

这是我的 Manifest.xml 的一部分

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock" >

谢谢

4

3 回答 3

10

不要使用android:theme="@style/Theme.Sherlock".

setTheme(R.style.Theme_Sherlock);在里面使用OnCreate

例如

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);

    // What you want to do here
}
于 2012-10-12T20:17:01.173 回答
2

你可以让你的风格继承自 Theme.Sherlock

<style name="MyAppTheme" parent="Theme.Sherlock">

然后在清单中使用您的主题

android:theme="@style/MyAppTheme"

您不必在每个页面上都使用 setTheme ,因为 Muz 说,当有更好的解决方案时,这似乎需要做很多工作,将上面的答案标记下来,但我不能!

于 2013-04-29T12:01:31.863 回答
2

我同意 matt_lethargic。在我的样式文件中是:

<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">

我的应用程序在我将其更改为后停止崩溃:

<style name="AppBaseTheme" parent="Theme.Sherlock">
于 2013-10-31T08:28:08.267 回答