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

前端 未结 7 1532
时光取名叫无心
时光取名叫无心 2020-11-27 21:37

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          


        
相关标签:
7条回答
  • 2020-11-27 21:49

    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.

    0 讨论(0)
  • 2020-11-27 21:55

    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>
    
    0 讨论(0)
  • 2020-11-27 21:56

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

    0 讨论(0)
  • 2020-11-27 22:02

    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.

    0 讨论(0)
  • 2020-11-27 22:09

    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.

    0 讨论(0)
  • 2020-11-27 22:10

    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.

    0 讨论(0)
提交回复
热议问题