InflateException: binary string of XML file # 22: bloat error on class <unknown>

When I try to run my application, it crashes and I get the following in logcat:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.application/com.example.application.StartActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class <unknown> 

.....

 Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class <unknown> 

.....

 Caused by: java.lang.reflect.InvocationTargetException 

.....

 Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1 

the error is also included in a line in my own code where I set the content view

this is an xml file referencing

 <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"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <RelativeLayout android:layout_width="match_parent" android:layout_height="200dp"> <TextView android:id="@+id/summonerName" android:layout_width="439dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:gravity="center_vertical" android:hint="@string/prompt_email" android:textSize="?android:textAppearanceLarge" android:singleLine="true" /> <Spinner android:id="@+id/region" android:layout_width="83dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/summonerName" android:layout_alignParentRight="true" /> <Button android:id="@+id/btnSearch" style="?android:textAppearanceSmall" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:background="#777" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:text="@string/action_sign_in" android:textColor="#FFF" android:textStyle="bold" /> </RelativeLayout> </LinearLayout> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#f3f3f4" android:choiceMode="singleChoice" android:divider="#dadadc" android:dividerHeight="1dp"/> 

I do not know what to do with these errors. Can someone help me on the right track?

+7
java android xml
source share
5 answers

I figured this out by reading this answer. The highlight I added caused an exception.

+3
source share

All your @dimens must be defined

eg

 <resources> <!-- Default margins, per the Android Design guidelines. --> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> </resources> 

You may have added those, for example, to these folders

  • values-sw600dp
  • Values-sw600dp-earth
  • Values-V19
  • xxhdpi values

Or any other folder, of course, where they can belong But don’t forget that they should also be in

  • values

They should also be defined there.

If this is not a problem, try creating a folder-XXXX for each layout-XXXX folder you have

  • xhdpi layout
  • xhdpi values

and

  • large layout
  • Value

eg

+2
source share

I had the same problem

The problem was that I used DrawerLayout and that my minSDK was installed below 14. A change that fixed the problem. The android support packages and adroid support for some reason allow you to use DrawerLayout, but there are no DrawerLayout definitions for layouts.

changing minSDK to 14 fixes the problem.

0
source share

This may be the reason for using high resolution resources. Check the permissible file permissions.

0
source share

For me, this was because the layout used android: theme = "@ style / AppTheme" in the parent Linear Layout. The application theme has been defined as:

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="actionBarTheme">@color/colorAccent</item> <item name="android:textColorPrimary">@color/white</item> <item name="android:textColorHint">@color/white</item> 

I deleted it and everything worked fine.

0
source share

All Articles