Skip to main content

Android: How to track down the origin of a InflateException?



While starting my application I get the following warning in Logcat:







04-09 10:28:17.830: WARN/WindowManager(52): Exception when adding starting window

04-09 10:28:17.830: WARN/WindowManager(52): android.view.InflateException: Binary XML file line #24: Error inflating class <unknown>

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.createView(LayoutInflater.java:513)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater.java:385)

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2153)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2207)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1395)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:818)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.server.WindowManagerService$H.handleMessage(WindowManagerService.java:8794)

04-09 10:28:17.830: WARN/WindowManager(52): at android.os.Handler.dispatchMessage(Handler.java:99)

04-09 10:28:17.830: WARN/WindowManager(52): at android.os.Looper.loop(Looper.java:123)

04-09 10:28:17.830: WARN/WindowManager(52): at com.android.server.WindowManagerService$WMThread.run(WindowManagerService.java:531)

04-09 10:28:17.830: WARN/WindowManager(52): Caused by: java.lang.reflect.InvocationTargetException

04-09 10:28:17.830: WARN/WindowManager(52): at android.widget.FrameLayout.<init>(FrameLayout.java:79)

04-09 10:28:17.830: WARN/WindowManager(52): at java.lang.reflect.Constructor.constructNative(Native Method)

04-09 10:28:17.830: WARN/WindowManager(52): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)

04-09 10:28:17.830: WARN/WindowManager(52): at android.view.LayoutInflater.createView(LayoutInflater.java:500)

04-09 10:28:17.830: WARN/WindowManager(52): ... 13 more

04-09 10:28:17.830: WARN/WindowManager(52): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-1}

04-09 10:28:17.830: WARN/WindowManager(52): at android.content.res.Resources.loadDrawable(Resources.java:1677)

04-09 10:28:17.830: WARN/WindowManager(52): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)

04-09 10:28:17.830: WARN/WindowManager(52): at android.widget.FrameLayout.<init>(FrameLayout.java:91)

04-09 10:28:17.830: WARN/WindowManager(52): ... 17 more







My Application starts with the following splash screen:







<?xml version="1.0" encoding="utf-8"?>

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

android:windowBackground="@color/white" android:background="@color/white"

android:layout_width="fill_parent" android:layout_height="fill_parent"

android:foregroundGravity="center">



<ImageView android:id="@+id/ImageView01"

android:layout_width="fill_parent" android:layout_height="fill_parent"

android:adjustViewBounds="true" android:scaleType="centerInside"

android:src="@drawable/splash" android:layout_gravity="center" />





</ScrollView>







Splash is the image that is shown in the splash screen. I have those four folders with for storing drawables in my app:





/res/drawable-hdpi


/res/drawable-ldpi


/res/drawable-mdpi


/res/drawable-nodpi





the splash image has its own version in the first three of them and is displayed properly. Removing the src property from the ImageView removes the image but not the exception.





I'm a little bit lost with where to look for the cause of the exception. I even don't know if this is really an issue in this layout file etc.





How would you go about finding the cause for this warning?


Comments

  1. I had the same exact error. The only xml line 24 that made any sense was my application manifest which happened to be the closing tag for application. I traced it down to my custom theme I was adding for the app -- I was not defining the parent of the style. All I needed to do was add parent="android:Theme" to my style and my error went away.

    <style name="MyTheme" parent="android:Theme">
    ...
    </style>

    ReplyDelete
  2. I got a similar error when running on a 2.0 emulator. I used a newer version of the API (version 7, 2.1-update1) and it worked.

    ReplyDelete
  3. 04-09 10:28:17.830: WARN/WindowManager(52): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x1010059 a=-1


    That line is the giveaway. The system isn't happy with one of your resources, probably a 'src' resource, probably android:src="@drawable/splash".

    ReplyDelete
  4. The error is on line 24 of your XML file. What does that line contain? By the looks of the error message

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


    you're using a custom class and haven't defined something properly. For example, did you define the package name properly? Maybe its constructor isn't formatted? We'd have to see the XML file, specifically what's around line 24, to be able to give more info.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.