What causes “RuntimeException: Binary XML file line #20: You must supply a layout_height attribute.” (ActionBarScherlock is suspected)?

若如初见. 提交于 2019-12-10 14:43:44

问题


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?


回答1:


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;
    }
}



回答2:


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.




回答3:


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.




回答4:


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">


来源:https://stackoverflow.com/questions/14529590/what-causes-runtimeexception-binary-xml-file-line-20-you-must-supply-a-layou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!