0

Background

I use ActionBarSherlock since I wish to handle old Android versions, and since the official Google's library for old Android devices doesn't have some important classes (like the PreferenceActivity or PreferenceFragment, so that they will have an actionBar).

The problem

Recently I got this weird exception:

java.lang.IllegalStateException: ActionBarView can only be used with android:layout_width="match_parent" (or fill_parent) at com.actionbarsherlock.internal.widget.ActionBarView.onMeasure(SourceFile:772) at android.view.View.measure(View.java:8322) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at com.actionbarsherlock.internal.widget.ActionBarContainer.onMeasure(SourceFile:181) at android.view.View.measure(View.java:8322) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017) at android.widget.LinearLayout.measureVertical(LinearLayout.java:386) at android.widget.LinearLayout.onMeasure(LinearLayout.java:309) at android.view.View.measure(View.java:8322) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at android.view.View.measure(View.java:8322) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138) at android.widget.FrameLayout.onMeasure(FrameLayout.java:250) at android.view.View.measure(View.java:8322) at android.view.ViewRoot.performTraversals(ViewRoot.java:876) at android.view.ViewRoot.handleMessage(ViewRoot.java:1911) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3821) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method)

And I can't find out why it occurs, as only a single user has reported it even though my app works fine on older Android versions (that I've tried).

What I've tried

I've found this post, and they say they don't know how to fix it other than just ditching old Android versions...

The question

Is it possible to fix this issue in some way? If so, how?

Will going to the official Google's library fix it somehow?

11
  • ABS is no longer maintained and it is highly recommended you move to AppCompat to use the actionbar. Since it is unknown as to what is causing the error it is also unknown as if moving to AppCompat will fix the problem. for all we know you could be doing something weird with your layouts
    – tyczj
    Jul 17, 2014 at 21:29
  • @tyczj I wrote that it works fine on all old Android versions I've tested, and that I use ABS because Google's library doesn't support PreferenceFragment and PreferenceActivity . Jul 17, 2014 at 21:45
  • PreferenceFragment and PreferenceActivity was never in the support library you have to check what version the device has at runtime and either display a PreferenceActivity if < SDK 11 or show PreferenceFragment if > SDK 11
    – tyczj
    Jul 17, 2014 at 21:52
  • @tyczj PreferenceActivity is available from API 1 , but it isn't in the support library: developer.android.com/reference/android/preference/… . The reason I want to have it is that it allows to have an action bar there. Jul 17, 2014 at 22:18
  • have a look at this library github.com/kolavar/android-support-v4-preferencefragment
    – tyczj
    Jul 17, 2014 at 22:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.