android.view.InflateException: Binary XML file line #12: Error inflating class

后端 未结 30 2305
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 13:48

I am receiving many errors of kind displayed in the subj. These errors seems to be occasional and I cannot reproduce them. From stack I can learn that such error may occurs

30条回答
  •  情深已故
    2020-11-22 14:40

    For me, the error message was actually insufficient in the log cat, so here's what I did to figure out what caused the problem:

    (In the log cat error message, it said the error occurred while inflating a specific layout in my HomeFragment.java)

    1. I put a breakpoint just before the layout was inflated
    2. I ran the application in debug mode until it reached that specific breakpoint
    3. I selected the line with my cursor and ran Evaluate expression on it:
      • Run > Evaluate Expression or alt - F8
    4. The result showed me more information about the source of the problem, which in my case, was a drawable file using tools:targetApi="lollipop" (the bug only occurred on older devices).

提交回复
热议问题