InflateException: Binary XML file line #8: Error inflating class ImageView
The stack trace doesn't show it, but the error during inflation might come from drawable used in the ImageView
, in this case:
android:src="@drawable/ic_dot"
OP tested this hunch, by trying a different drawable which "seems ok right now...".
Binary XML file line #0: Error inflating class ImageView
Some SVGs sources seem to not be fully supported. Add below line within your activity's onCreate() method:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
and make sure you use below as attribute to your ImageView in your xml file:
app:srcCompact instead of android:src to define your image.
Error inflating class ImageView - android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
As you see in last lines of error:
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12
seems you entered something that is not a dimension where you must.
And as documentation of attribute android:baseline
:
The offset of the baseline within this view. May be a dimension value,
which is a floating point number appended with a unit such as
"14.5sp". Available units are: px (pixels), dp (density-independent
pixels), sp (scaled pixels based on preferred font size), in (inches),
and mm (millimeters).
But you used a string for value of baseline.
InflateException: Error inflating class ImageView for VectorDrawableCompat
I believe the problem is android:src="@drawable/mypic"
in your imageView setup.
Change that toapp:srcCompat="@drawable/mypic"
Then you should be good to go.
More details, please refer to:
https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.mvuq06x1k
Error inflating class ImageView in android
To use srcCompat
you need to add vectorDrawables.useSupportLibrary = true
to your build.gradle file:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Or you can use src
instead of srcCompat
to resolve the error.
android:src="@drawable/search"
Related Topics
How to Crop a Bitmap for Imageview
Could Not Find Method in Parent or Ancestor Context
Multidex Noclassdeffound Error
Android - Bitmap Cache Takes a Lot of Memory
Android - Imageloader Must Be Init with Configuration Before Using in Uil
Bitmap Getwidth Returns Wrong Value
Multiple Dex Files Define <My Package>/Buildconfig, Can't Find the Cause:
Binary Xml File Line #0: Error Inflating Class Imageview
Boot_Completed Not Working on Android 10 Q API Level 29
Gson Expected Begin_Array But Was Begin_Object
R.Raw.Anything Cannot Be Resolved
How to Iterate Through the Id Properties of R.Java Class
Get Current Time in a Given Timezone:Android