Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12

Tags:

So my problem is a weird one. I keep getting this error:

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12 

The weird part is that it only happens on 4.1.2. I've tested 4.0.3, 4.2.2, 4.3 and 4.4. All work perfectly except 4.1.2. Since 4.0.3 works, 4.1.2 technically should too so I just can't figure out what's wrong.

Here's my activity_main.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fitsSystemWindows="true" tools:context="-removed name-">   <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/drawer_layout"     android:layout_width="match_parent"     android:layout_height="match_parent">      <!-- FrameLayout to display Fragments -->     <FrameLayout         android:id="@+id/frame_container"         android:layout_width="match_parent"         android:layout_height="match_parent" />      <!-- ListView to display slider menu -->     <ListView         android:id="@+id/list_slidermenu"         android:layout_width="240dp"         android:layout_height="match_parent"         android:layout_gravity="start"         android:choiceMode="singleChoice"         android:divider="@color/list_divider"         android:dividerHeight="1dp"         android:listSelector="@drawable/list_selector"         android:background="@color/list_background" /> </android.support.v4.widget.DrawerLayout> </FrameLayout> 

And here's my fragment_layout.xml:

 <RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent"  android:layout_height="fill_parent">   <Spinner  android:layout_width="match_parent"  android:layout_height="48dp"  android:id="@+id/spinner_convertFrom"  android:spinnerMode="dialog"  android:layout_marginLeft="16dp"  android:layout_marginRight="4dp"  android:layout_alignRight="@+id/button"  android:layout_alignTop="@+id/spinner_convertTo" />  <Spinner android:layout_width="match_parent" android:layout_height="48dp" android:id="@+id/spinner_convertTo" android:spinnerMode="dialog" android:layout_marginRight="16dp" android:layout_marginLeft="4dp" android:layout_alignLeft="@+id/button" android:layout_marginTop="90dp" />  <EditText android:layout_width="wrap_content" android:layout_height="48dp" android:inputType="numberDecimal|numberSigned" android:ems="10" android:id="@+id/editText_convert" android:gravity="center" android:imeOptions="actionDone" android:selectAllOnFocus="true" android:layout_marginBottom="30dp" android:layout_above="@+id/button_Convert" android:layout_centerHorizontal="true" />  <Button android:layout_width="wrap_content" android:layout_height="48dp" android:text="@string/convert_button" android:id="@+id/button_Convert" android:clickable="true" android:gravity="center" android:layout_marginBottom="40dp" android:layout_above="@+id/textView_result" android:layout_centerHorizontal="true"/>  <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/convert_from" android:id="@+id/textView_convertFrom" android:textSize="14sp" android:layout_alignLeft="@+id/spinner_convertFrom" android:layout_marginBottom="8dp" android:layout_alignTop="@+id/textView_ConvertTo" />  <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/convert_to" android:id="@+id/textView_ConvertTo" android:textSize="14sp" android:layout_alignLeft="@+id/spinner_convertTo" android:layout_marginTop="74dp" />  <TextView android:layout_width="wrap_content" android:layout_height="120dp" android:text="@string/result_box" android:id="@+id/textView_result" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="16dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:gravity="center" android:singleLine="false" android:textIsSelectable="true" android:background="@drawable/result_border" />  <Button style="?android:attr/buttonStyleSmall" android:layout_width="0dp" android:layout_height="0dp" android:id="@+id/button" android:layout_centerHorizontal="true" />  </RelativeLayout> 

I've searched through all the similar questions but their solutions won't work for me.

Full log:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{-removed name-/-removed name-.MainActivity}: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)         at android.app.ActivityThread.access$600(ActivityThread.java:130)         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)         at android.os.Handler.dispatchMessage(Handler.java:99)         at android.os.Looper.loop(Looper.java:137)         at android.app.ActivityThread.main(ActivityThread.java:4745)         at java.lang.reflect.Method.invokeNative(Native Method)         at java.lang.reflect.Method.invoke(Method.java:511)         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)         at dalvik.system.NativeStart.main(Native Method)  Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12         at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)         at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:5616)         at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1809)         at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1721)         at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:58)         at android.view.LayoutInflater.rInflate(LayoutInflater.java:748)         at android.view.LayoutInflater.inflate(LayoutInflater.java:489)         at android.view.LayoutInflater.inflate(LayoutInflater.java:396)         at android.view.LayoutInflater.inflate(LayoutInflater.java:352)         at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2784)         at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2844)         at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)         at android.app.Activity.setContentView(Activity.java:1867)         at -removed name-.MainActivity.onCreate(MainActivity.java:41)         at android.app.Activity.performCreate(Activity.java:5008)         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 

The entire logcat didn't post. Here's the rest:

at android.app.ActivityThread.access$600(ActivityThread.java:130) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) 

Styles.xml:

<resources xmlns:tools="http://schemas.android.com/tools">  <style name="AppTheme" parent="@android:style/Theme.Holo">     <item name="android:popupMenuStyle">@style/PopupMenu.Konvertr</item>     <item name="android:actionBarStyle">@style/ActionBar.Solid.Konvertr</item>     <item name="android:windowBackground">@color/window_bg</item>     <item name="android:windowTranslucentNavigation" tools:targetApi="19">true</item>     <item name="android:dropDownSpinnerStyle">@style/SpinnerAppTheme</item> </style>  <style name="ActionBar.Solid.Konvertr" parent="@android:style/Widget.Holo.ActionBar.Solid">     <item name="android:background">@drawable/ab_background_textured_konvertr</item>     <item name="android:backgroundStacked">@drawable/ab_stacked_solid_konvertr</item>     <item name="android:backgroundSplit">@drawable/ab_background_textured_konvertr</item> </style>  <style name="ActionBar.Transparent.Konvertr" parent="@android:style/Widget.Holo.ActionBar">     <item name="android:background">@drawable/ab_transparent_konvertr</item> </style>  <style name="PopupMenu.Konvertr" parent="@android:style/Widget.Holo.ListPopupWindow">     <item name="android:popupBackground">@drawable/menu_dropdown_panel_konvertr</item> </style>  <style name="SpinnerAppTheme" parent="@android:Widget.Holo.Spinner">     <item name="android:background">@drawable/apptheme_spinner_background_holo_dark</item> </style> 

like image 224
Runedrune Avatar asked Feb 17 '14 06:02

Runedrune


1 Answers

You should add android:windowTranslucentNavigation attribute in values-v19 style.

It is not supported in older versions.

like image 91
Yaroslav Mytkalyk Avatar answered Nov 03 '22 01:11

Yaroslav Mytkalyk