UnsupportedOperationException: Can't convert to dimension: type=0x1

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:

<?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.

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

  • values-sw600dp
  • values-sw720dp-land

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.


In my case the problem was

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

instead of:

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

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

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

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