引起:java.lang.UnsupportedOperationException:无法转换为dimension:type = 0x1

时间:2023-02-10 18:57:20

In Android I got following Error in emulator and some mobile device but not in Tablet:

在Android中,我在模拟器和一些移动设备中遇到以下错误但在平板电脑中没有:

I don't understand what error is there?

我不明白有什么错误?

I have searched many tutorials but can't find any solution.

我搜索了很多教程但找不到任何解决方案。

Please Help me to solve this.

请帮我解决这个问题。

Note: In this application i have used ActionbarSherlock and theme, may i got because of that library or any other problem?

注意:在这个应用程序中,我使用了ActionbarSherlock和主题,可能是因为该库或任何其他问题?

My Error Log is:

我的错误日志是:

09-11 17:52:57.342: E/AndroidRuntime(9935): FATAL EXCEPTION: main
09-11 17:52:57.342: E/AndroidRuntime(9935): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:193)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.Spinner.onMeasure(Spinner.java:439)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1217)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.ScrollView.onMeasure(ScrollView.java:321)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.View.measure(View.java:15518)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.Choreographer.doFrame(Choreographer.java:532)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.os.Handler.handleCallback(Handler.java:725)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.os.Looper.loop(Looper.java:137)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.app.ActivityThread.main(ActivityThread.java:5041)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at java.lang.reflect.Method.invokeNative(Native Method)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at java.lang.reflect.Method.invoke(Method.java:511)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at dalvik.system.NativeStart.main(Native Method)
09-11 17:52:57.342: E/AndroidRuntime(9935): Caused by: java.lang.reflect.InvocationTargetException
09-11 17:52:57.342: E/AndroidRuntime(9935):     at java.lang.reflect.Constructor.constructNative(Native Method)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
09-11 17:52:57.342: E/AndroidRuntime(9935):     ... 45 more
09-11 17:52:57.342: E/AndroidRuntime(9935): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.TextView.<init>(TextView.java:916)
09-11 17:52:57.342: E/AndroidRuntime(9935):     at android.widget.TextView.<init>(TextView.java:578)
09-11 17:52:57.342: E/AndroidRuntime(9935):     ... 48 more

My XML Layout file is:

我的XML布局文件是:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:panel="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/activity_vertical_margin"
        android:layout_marginLeft="@dimen/other_activity_horizontal_margin"
        android:layout_marginRight="@dimen/other_activity_horizontal_margin"
        android:layout_marginTop="@dimen/activity_vertical_margin"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/custDetailsNameEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:hint="@string/name_cust_all_add"
            android:inputType="textPersonName"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsEmailEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsNameEditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/email_cust_all_add"
            android:inputType="textEmailAddress"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Spinner
            android:id="@+id/custDetailsDistributorSpinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsEmailEditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:entries="@array/slide_menu_items"
            android:prompt="@string/select_distributor_prompt_add"
            android:spinnerMode="dialog" >
        </Spinner>

        <EditText
            android:id="@+id/custDetailsAddress1TitleEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsDistributorSpinner"
            android:layout_marginTop="15dp"
            android:hint="@string/address_1_cust_all_add"
            android:inputType="textPostalAddress"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsAddress2TitleEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsAddress1TitleEditText"
            android:layout_marginTop="15dp"
            android:hint="@string/address_2_cust_all_add"
            android:inputType="textPostalAddress"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsAddress3TitleEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsAddress2TitleEditText"
            android:layout_marginTop="15dp"
            android:hint="@string/address_3_cust_all_add"
            android:inputType="textPostalAddress"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <Spinner
            android:id="@+id/custDetailsCompanyAreaSpinner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsAddress3TitleEditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:entries="@array/slide_menu_items"
            android:prompt="@string/select_company_area_prompt_add"
            android:spinnerMode="dialog" 
            android:fastScrollEnabled="true"
            >
        </Spinner>

        <EditText
            android:id="@+id/custDetailsPincodeEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsCompanyAreaSpinner"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/pincode_cust_all_add"
            android:inputType="number"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsPhone1EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsPincodeEditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/phone_1_cust_all_add"
            android:inputType="phone"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsPhone2EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsPhone1EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/phone_2_cust_all_add"
            android:inputType="phone"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsMobileNo1EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsPhone2EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/mobile_no_1_cust_all_add"
            android:inputType="phone"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsMobileNo2EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsMobileNo1EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/mobile_no_2_cust_all_add"
            android:inputType="phone"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsContactPerson1EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsMobileNo2EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/contact_person_1_cust_all_add"
            android:inputType="text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsContactPerson2EditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsContactPerson1EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/contact_person_2_cust_all_add"
            android:inputType="text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsTinNoEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsContactPerson2EditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/tin_no_cust_all_add"
            android:inputType="text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <EditText
            android:id="@+id/custDetailsCstNoEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsTinNoEditText"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="15dp"
            android:hint="@string/cst_no_cust_all_add"
            android:inputType="text"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <RadioGroup
            android:id="@+id/custDetailsVTVRRadioGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsCstNoEditText"
            android:layout_marginTop="15dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/custDetailsVTVRLableTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/vt_vr_cust_all_add"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <RadioButton
                android:id="@+id/custDetailsVTRadioButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="@string/vt_cust_all_add" />

            <RadioButton
                android:id="@+id/custDetailsVRRadioButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/vr_cust_all_add" />
        </RadioGroup>

        <RadioGroup
            android:id="@+id/custDetailsCFormRadioGroup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/custDetailsVTVRRadioGroup"
            android:layout_marginTop="15dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/custDetailsCFormLableTextView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/c_form_cust_add_all"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <RadioButton
                android:id="@+id/custDetailsCFormYesRadioButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="@string/yes_cust_add_all" />

            <RadioButton
                android:id="@+id/custDetailsCFormNoRadioButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/no_cust_add_all" />
        </RadioGroup>
    </RelativeLayout>

</ScrollView>

styles.xml in values folder:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <style name="SlideBarTheme" parent="@style/Theme.Sherlock.NoActionBar">
        <item name="android:background">@drawable/slide_bg</item>
        <item name="android:cacheColorHint">@android:color/transparent</item>
        <item name="android:choiceMode">singleChoice</item>
    </style>

    <style name="ActivityTheme" parent="@style/Theme.Sherlock.Light">
        <item name="android:textColor">@color/activity_text</item>
        <item name="android:background">@color/activity_background</item>
    </style>

    <!-- For Widget -->

    <style name="MyAndroidTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
        <item name="android:editTextStyle">@style/EditTextAppTheme</item>
        <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
        <item name="android:checkboxStyle">@style/CheckBoxAppTheme</item>
        <item name="android:spinnerStyle">@style/SpinnerAppTheme</item>
        <item name="android:dropDownSpinnerStyle">@style/SpinnerAppTheme.DropDown</item>
        <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItemAppTheme</item>
        <item name="android:listViewStyle">@style/ListViewAppTheme</item>
        <item name="android:listViewWhiteStyle">@style/ListViewAppTheme.White</item>
        <item name="android:spinnerItemStyle">@style/SpinnerItemAppTheme</item>
    </style>

</resources>

styles.xml in values-11 folder:

    <resources>

    <!--
        Base application theme for API 11+. This theme completely replaces
        AppBaseTheme from res/values/styles.xml on API 11+ devices.
    -->

    <!-- API 11 theme customizations can go here. -->
    <style name="MyAndroidTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="android:editTextBackground">@drawable/edit_text_holo_light</item>
        <item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
        <item name="android:listChoiceIndicatorMultiple">@drawable/btn_check_holo_light</item>
        <item name="android:dropDownSpinnerStyle">@style/SpinnerAppTheme</item>
        <item name="android:listChoiceBackgroundIndicator">@drawable/list_selector_holo_light</item>
        <item name="android:activatedBackgroundIndicator">@drawable/activated_background_holo_light</item>
    </style>

</resources>

styles.xml in values-14 folder:

<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>

and also i have custom theme file:

我也有自定义主题文件:

In values folder named styles_apptheme.xml and styles_myactionbar.xml, In values-v11 folder named styles_apptheme.xml, In values-v14 folder named styles_myactionbar.xml

在名为styles_apptheme.xml和styles_myactionbar.xml的values文件夹中,在名为styles_apptheme.xml的values-v11文件夹中,在名为styles_myactionbar.xml的values-v14文件夹中

What should i change.?

我该怎么改变?

Your Help would Be Appreciated.

您的帮助将得到赞赏。

Thanks in Advance...

提前致谢...

10 个解决方案

#1


155  

After 2 days I found the solution; from the layout as defined in my question, I have a Spinner which is bound with a custom TextView:

2天后我找到了解决方案;从我的问题中定义的布局,我有一个Spinner与自定义TextView绑定:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listTextViewSpinner"
    ...
    android:textSize="@dimen/spinner_list_item_text_size"
    ... />

Here, I have an extracted dimension resource: @dimen/spinner_list_item_text_size.

在这里,我有一个提取的维度资源:@ dimen / spinner_list_item_text_size。

This has been defined in dimens.xml in the following directories:

这已在以下目录的dimens.xml中定义:

  • values-sw600dp
  • 价值观sw600dp
  • values-sw720dp-land
  • 价值观sw720dp土地

but crucially I forgot to define it in

但至关重要的是我忘了定义它

  • values

After defining the resource (@dimen/spinner_list_item_text_size) in values/dimens.xml,it works successfully.

在values / dimens.xml中定义资源(@ dimen / spinner_list_item_text_size)后,它可以成功运行。

#2


18  

You find in your logcat before the exception a line like this:

你可以在异常之前的logcat中找到这样一行:

08-19 10:05:58.008: W/ResourceType(3999): Failure getting entry for 0x7f0a005f (t=9 e=95) in package 0 (error -75)

08-19 10:05:58.008:W / ResourceType(3999):无法在包0中输入0x7f0a005f(t = 9 e = 95)(错误-75)

Search for tis number (here 0x7f0a005f) in the generated Resource.class R.java. The name of the variable is the missing dimen-resource.

在生成的Resource.class R.java中搜索tis号(此处为0x7f0a005f)。变量的名称是缺少的dimen-resource。

#3


6  

For others that get here from a Google search, make sure you're assigning a dimension instead of something else. The logcat will point you to the problem view.

对于从Google搜索到达此处的其他人,请确保您分配的是维度而不是其他内容。 logcat将指向您的问题视图。

i.e. Somehow, 1 of my layouts had a couple of TextViews with android:textSize="?android:attr/textAppearanceSmall"

即不知何故,我的布局中有一个有几个带有android的TextView:textSize =“?android:attr / textAppearanceSmall”

Renamed them to android:textAppearance="?android:attr/textAppearanceSmall" and all is well again.

将它们重命名为android:textAppearance =“?android:attr / textAppearanceSmall”,一切都很好。

#4


6  

I my case the problem was

我的情况是问题所在

<dimen name="name">12</dimen>

instead of:

代替:

<dimen name="name">12dp</dimen>

#5


3  

You can have a look to this thread, the problem seems to be exactly the one you're having:

你可以看看这个帖子,问题似乎正是你所拥有的:

https://github.com/JakeWharton/ActionBarSherlock/issues/446

https://github.com/JakeWharton/ActionBarSherlock/issues/446

It seems the trick is to do the following:

似乎诀窍是做以下事情:

I met the same problem today, i couldn't find the reason but finally got a solution. It seems that you cannot put any properties that M9 cannot recognize int theme.xml, just like android:actionBarStyle. So the solution is to make a new theme.xml in value-v14, and put all these properties in it.

我今天遇到了同样的问题,我找不到原因,但终于得到了解决方案。看来你不能把任何M9无法识别的属性设置在theme.xml中,就像android:actionBarStyle一样。所以解决方案是在value-v14中创建一个新的theme.xml,并将所有这些属性放入其中。

Good luck!

祝你好运!

#6


3  

Solved: I had the same error, But it turns out i forgot to define a value in dimens.xml yet i had defined it in dimens.xml(w820dp). Make sure all the values are defined. Worked for me

解决:我有同样的错误,但事实证明我忘了在dimens.xml中定义一个值,但我已经在dimens.xml(w820dp)中定义了它。确保定义了所有值。为我工作

#7


1  

For me the problem was the value in the dimension.

对我来说,问题是维度的价值。

<dimen name="general_container_width">@dimen/match_parent</dimen>

@ dimen / match_parent

android was not able to resolve the @dimen/match_parent when I was trying to get the value in my custom view.

当我试图在我的自定义视图中获取值时,android无法解析@ dimen / match_parent。

#8


0  

just add in root tools:ignore="ContentDescription"

只需添加root工具:ignore =“ContentDescription”

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="ContentDescription" >

#9


0  

And for me it was a bad styles.xml that defined a textSize incorrectly:-

对我来说,这是一个错误的styles.xml,它错误地定义了textSize: -

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" >
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:gravity">center</item>
        <item name="android:textSize">@style/TextAppearance.AppCompat.Small</item>
    </style>

    ...
</resources>

The hint came from the following stack trace and realizing that the above was one of the size related changes I made since last successful run.

提示来自以下堆栈跟踪,并意识到上面是我上次成功运行后所做的与大小相关的更改之一。

 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
                                                                      at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
                                                                      at android.widget.TextView.<init>(TextView.java:972)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
                                                                      at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
                                                                      at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
                                                                      at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
                                                                      at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:615)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:636)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:333)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
                                                                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                      at com.edsglobal.ecbc.AMAinActivity.onCreate(AMAinActivity.java:94)
                                                                      at android.app.Activity.performCreate(Activity.java:5231)
                                                                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                                                                      at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                      at android.os.Looper.loop(Looper.java:136) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5017) 
                                                                      at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                      at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                                                                      at dalvik.system.NativeStart.main(Native Method) 

#10


0  

Paweł Dedio your answer did it for me. After reading the logcat. In dimens.xml I had to change

PawełDedio你的回答为我做了。看完logcat后。在dimens.xml中,我不得不改变

From    <dimen name="view_margin_top">16</dimen>
    <dimen name="reset_side_margin">22</dimen>
    <dimen name="linear_width">0dp</dimen>
To

    <dimen name="view_margin_top">16dp</dimen>
    <dimen name="reset_side_margin">22dp</dimen>
    <dimen name="linear_width">0dp</dimen>

#1


155  

After 2 days I found the solution; from the layout as defined in my question, I have a Spinner which is bound with a custom TextView:

2天后我找到了解决方案;从我的问题中定义的布局,我有一个Spinner与自定义TextView绑定:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listTextViewSpinner"
    ...
    android:textSize="@dimen/spinner_list_item_text_size"
    ... />

Here, I have an extracted dimension resource: @dimen/spinner_list_item_text_size.

在这里,我有一个提取的维度资源:@ dimen / spinner_list_item_text_size。

This has been defined in dimens.xml in the following directories:

这已在以下目录的dimens.xml中定义:

  • values-sw600dp
  • 价值观sw600dp
  • values-sw720dp-land
  • 价值观sw720dp土地

but crucially I forgot to define it in

但至关重要的是我忘了定义它

  • values

After defining the resource (@dimen/spinner_list_item_text_size) in values/dimens.xml,it works successfully.

在values / dimens.xml中定义资源(@ dimen / spinner_list_item_text_size)后,它可以成功运行。

#2


18  

You find in your logcat before the exception a line like this:

你可以在异常之前的logcat中找到这样一行:

08-19 10:05:58.008: W/ResourceType(3999): Failure getting entry for 0x7f0a005f (t=9 e=95) in package 0 (error -75)

08-19 10:05:58.008:W / ResourceType(3999):无法在包0中输入0x7f0a005f(t = 9 e = 95)(错误-75)

Search for tis number (here 0x7f0a005f) in the generated Resource.class R.java. The name of the variable is the missing dimen-resource.

在生成的Resource.class R.java中搜索tis号(此处为0x7f0a005f)。变量的名称是缺少的dimen-resource。

#3


6  

For others that get here from a Google search, make sure you're assigning a dimension instead of something else. The logcat will point you to the problem view.

对于从Google搜索到达此处的其他人,请确保您分配的是维度而不是其他内容。 logcat将指向您的问题视图。

i.e. Somehow, 1 of my layouts had a couple of TextViews with android:textSize="?android:attr/textAppearanceSmall"

即不知何故,我的布局中有一个有几个带有android的TextView:textSize =“?android:attr / textAppearanceSmall”

Renamed them to android:textAppearance="?android:attr/textAppearanceSmall" and all is well again.

将它们重命名为android:textAppearance =“?android:attr / textAppearanceSmall”,一切都很好。

#4


6  

I my case the problem was

我的情况是问题所在

<dimen name="name">12</dimen>

instead of:

代替:

<dimen name="name">12dp</dimen>

#5


3  

You can have a look to this thread, the problem seems to be exactly the one you're having:

你可以看看这个帖子,问题似乎正是你所拥有的:

https://github.com/JakeWharton/ActionBarSherlock/issues/446

https://github.com/JakeWharton/ActionBarSherlock/issues/446

It seems the trick is to do the following:

似乎诀窍是做以下事情:

I met the same problem today, i couldn't find the reason but finally got a solution. It seems that you cannot put any properties that M9 cannot recognize int theme.xml, just like android:actionBarStyle. So the solution is to make a new theme.xml in value-v14, and put all these properties in it.

我今天遇到了同样的问题,我找不到原因,但终于得到了解决方案。看来你不能把任何M9无法识别的属性设置在theme.xml中,就像android:actionBarStyle一样。所以解决方案是在value-v14中创建一个新的theme.xml,并将所有这些属性放入其中。

Good luck!

祝你好运!

#6


3  

Solved: I had the same error, But it turns out i forgot to define a value in dimens.xml yet i had defined it in dimens.xml(w820dp). Make sure all the values are defined. Worked for me

解决:我有同样的错误,但事实证明我忘了在dimens.xml中定义一个值,但我已经在dimens.xml(w820dp)中定义了它。确保定义了所有值。为我工作

#7


1  

For me the problem was the value in the dimension.

对我来说,问题是维度的价值。

<dimen name="general_container_width">@dimen/match_parent</dimen>

@ dimen / match_parent

android was not able to resolve the @dimen/match_parent when I was trying to get the value in my custom view.

当我试图在我的自定义视图中获取值时,android无法解析@ dimen / match_parent。

#8


0  

just add in root tools:ignore="ContentDescription"

只需添加root工具:ignore =“ContentDescription”

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="ContentDescription" >

#9


0  

And for me it was a bad styles.xml that defined a textSize incorrectly:-

对我来说,这是一个错误的styles.xml,它错误地定义了textSize: -

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar" >
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:gravity">center</item>
        <item name="android:textSize">@style/TextAppearance.AppCompat.Small</item>
    </style>

    ...
</resources>

The hint came from the following stack trace and realizing that the above was one of the size related changes I made since last successful run.

提示来自以下堆栈跟踪,并意识到上面是我上次成功运行后所做的与大小相关的更改之一。

 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
                                                                      at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
                                                                      at android.widget.TextView.<init>(TextView.java:972)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
                                                                      at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
                                                                      at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
                                                                      at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
                                                                      at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
                                                                      at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:615)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:636)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:333)
                                                                      at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:289)
                                                                      at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                      at com.edsglobal.ecbc.AMAinActivity.onCreate(AMAinActivity.java:94)
                                                                      at android.app.Activity.performCreate(Activity.java:5231)
                                                                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                                                                      at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                                                                      at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                      at android.os.Looper.loop(Looper.java:136) 
                                                                      at android.app.ActivityThread.main(ActivityThread.java:5017) 
                                                                      at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                      at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                                                                      at dalvik.system.NativeStart.main(Native Method) 

#10


0  

Paweł Dedio your answer did it for me. After reading the logcat. In dimens.xml I had to change

PawełDedio你的回答为我做了。看完logcat后。在dimens.xml中,我不得不改变

From    <dimen name="view_margin_top">16</dimen>
    <dimen name="reset_side_margin">22</dimen>
    <dimen name="linear_width">0dp</dimen>
To

    <dimen name="view_margin_top">16dp</dimen>
    <dimen name="reset_side_margin">22dp</dimen>
    <dimen name="linear_width">0dp</dimen>