5

I have app with ActionBarScherlock and I use ACRA. I receive crash reports from some users with following error:

"java.lang.RuntimeException: Binary XML file line #20: You must supply a layout_height attribute.
    at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
    at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3602)
    at android.view.ViewGroup$LayoutParams.<init>(ViewGroup.java:3554)
    at android.widget.AbsListView$LayoutParams.<init>(AbsListView.java:4322)
    at android.widget.AbsListView.generateLayoutParams(AbsListView.java:4116)
    at android.widget.AbsListView.generateLayoutParams(AbsListView.java:74)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
    at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
    at android.webkit.WebTextView$AutoCompleteAdapter.getView(WebTextView.java:650)
    at android.widget.AbsListView.obtainView(AbsListView.java:1430)
    at android.widget.AutoCompleteTextView$DropDownListView.obtainView(AutoCompleteTextView.java:1548)
    at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
    at android.widget.AutoCompleteTextView.buildDropDown(AutoCompleteTextView.java:1376)
    at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1140)
    at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:1022)
    at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:1005)
    at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3717)
    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:864)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
    at dalvik.system.NativeStart.main(Native Method)"

Of course I've tried to google it and found that it is most likely caused by ActionBarScherlock (and I noticed that every user who encountered with this error uses android 2.3.*) but haven't found a solution. It's a bit disconcerting that I can't reproduce this error on my own 2.3.* device...

So, what causes this error?

janot
  • 13,578
  • 1
  • 27
  • 57

4 Answers4

14

In my case this was due to a problem with ActionBarsherlock.

In my Android manifest I had android:theme="@style/AppTheme" then when you go to styles, i saw my AppTheme's parent was "AppBaseTheme". This was the problem!

<style name="AppTheme" parent="AppBaseTheme">

I changed this to

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

And my problem was solved.

jprofitt
  • 10,874
  • 4
  • 36
  • 46
Larzzz
  • 183
  • 1
  • 9
2

The layout_height in this instance is defined as ?attr/actionBarSize which is a theme attribute with a value of @dimen/action_bar_height that is defined in three places: values/, values-land/, and values-sw600dp/.

This is usually cased by OEMs who've tinkered with the resource system causing some aspect of this chain to not load correctly. There's nothing we can really do, as far as I'm aware.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • do you have any references to support this theory (that it is OEM's fault). I suspect you are correct, just looking for more info. – SteelBytes Nov 07 '15 at 05:17
2

I had same problem and solve it by change in AndroidManifest.xml. You have to set theme of particular Activity or complete application to Theme.Sherlock.Light (I think you can specify only Theme.Sherlock).

In code it will be:

<application 
    ... 
    android:theme="@style/Theme.Sherlock.Light">

or

<activity
    ... 
    android:theme="@style/Theme.Sherlock.Light">
SlovaN
  • 326
  • 2
  • 10
2

One of our #1 crashes came from this issue, especially on ZTE devices. While the actionbar worked on most screens, we were getting this crash when users interacted with a Webview Edittext/InputBox. The crash happened as a result of autocomplete on the Webview. Disabling autocomplete seemed to eliminate the crashes. Why autocomplete should have anything to do with the Actionbar is still a mystery.

Here we disable the autocomplete just for ZTE devices. We may expand the list later if we have problems on other devices.

    public static boolean disableWebViewAutoCompleteForDevicesThatCrash(WebView webView)
{
    // We may add some other bizarre devices to this list if the ZTE fix works well.
    if ("ZTE".equals(Build.MANUFACTURER))
    {
        webView.getSettings().setSaveFormData(false);
        webView.clearFormData();
        return true;
    }
    else
    {
        return false;
    }
}
joseph
  • 1,165
  • 1
  • 7
  • 16
  • Unforunately I have no ability to test this issue anymore, but my app was mainly based on WebView, so your solution is probably suitable. – janot Sep 10 '13 at 06:23
  • Ah and I remebered, that I also had this error mostly (or even only) on ZTE devices – janot Sep 24 '13 at 07:41