40

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?

Janusz
  • 187,060
  • 113
  • 301
  • 369
  • Well, look for a file that has 24 lines `XML file line #24` – Pentium10 Apr 09 '10 at 08:43
  • 6
    Nearly all my layout files are longer then 24 lines. – Janusz Apr 09 '10 at 09:26
  • I had a similar problem when setting a nondrawable (dimention in my case) on a style attribute that expected a drawable. I would expect the builder (XML sanitiser?) to warn you before a build happens. – Diederik Jun 21 '12 at 11:58

7 Answers7

53

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>
Garrett
  • 546
  • 4
  • 3
3

I had the same issue, and it was because I passed the application context instead of the activity context.

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
2
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".

Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
  • I removed the src property and both background properties both without success now the splash screen is empty but the exception is still there. – Janusz Apr 09 '10 at 09:22
  • Eesh. OK, next step, try removing the whole ImageView tag to see if it's something in that tag causing the problem. – Jim Blackler Apr 09 '10 at 09:29
  • 1
    Done that too. No help. I think it may another XML file. Like the file defining the styles for the whole app etc but I don't know where to look. – Janusz Apr 09 '10 at 11:30
  • 2
    Are you applying a theme to the Activity in AndroidManifest.xml? – Jim Blackler Apr 09 '10 at 12:14
1

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.

Nada
  • 19
  • 1
0

I know this is a bit late but I spent all day trying to figure this one out and finally with the help of this SO question I realized an XML file in the example I was trying out was using a feature from a later API and Lint wasn't catching it because the file hadn't changed. As soon as I did a random edit on the XML file and saved the file then the error about a later API showed up.

Community
  • 1
  • 1
Gravitoid
  • 1,294
  • 1
  • 20
  • 20
0

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.

Steve Haley
  • 55,374
  • 17
  • 77
  • 85
  • The first screen that is shown after the exception occurs is the splashscreen and this xml file is not 24 lines long. And the binary in front of th XML says me that I won't find anyting at a line 24 in my XML files. – Janusz Apr 09 '10 at 11:29
  • I don't know why it specifies `binary` before saying it's XML file line #24, but that *is* the line with the problem in it. I just introduced a deliberate error in one of my XML files (renamed a custom View to something that didn't exist) and I got a similar exception log to yours. It said `android.view.InflateException: Binary XML file line #90: Error inflating class (mypackage.myclass...)`. So, you need to figure out which XML file it's opening, then look at line 24. For example, do you have another activity beneath your splash screen? – Steve Haley Apr 09 '10 at 11:58
  • Sorry, I meant to add more detail about my error message. It reported the line with the fault as being #90, and that was the exact line with the problem - I counted it by hand. Then the line number correctly changed as I modified the file and moved things around. So we know that there's a line 24 in one of your files causing trouble, even though the root cause might be somewhere else. If there's another activity visible beneath your splash screen, there might be an error inflating the XML file for that one. – Steve Haley Apr 09 '10 at 12:23
  • It's weird, I got the same problem as OP, but the current XML i'm loading only has 8 lines, my manifest has 6... it still says Line 24 o_O any ideas? – ForceMagic Jul 18 '13 at 16:11
-1

After so many hectic research on finding the answer that why App is crashing and why its not showing the logcat

I have just replaced this

android:configChanges="orientation|keyboardHidden"

to

android:configChanges="keyboardHidden|orientation|screenSize"

in the activity tag.

Ahmad Arslan
  • 4,498
  • 8
  • 38
  • 59