BUG modify Diary - Android Fragment beginner - Binary XML file line #XX: Error inflating class fragment

First blogging, if not, a lot of generosity.

Background: The recent school lesson requires Android exercise first line of code Android 4.5 news app practice, to be used to fragment, recyclerview and other controls, but according to the book written step by step, there app can not open the case. Initial modified, to no avail. Really depressing, irritability, want to hit the computer, for computer security, back-burner, now try again, successfully resolved.

An older version of the book, Android Stdio 3.5 I use.

Error phenomenon:
Here Insert Picture Description
Here Insert Picture Description

Unable to start activity ComponentInfo{com.example.news_201717225110/com.example.news_201717225110.MainActivity}: android.view.InflateException: Binary XML file line #20: Error inflating class fragment

Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class fragment

Analysis: see, reference being given fragment, but only mark the error message in the error rendering the error position can not be determined, the main observation corresponding code fragment, the development for Baidu, this error is not marked fragment id or name / class [^ 1], but the view has not found such an error, lost in thought.

Treatment: failed to direct observation errors, the use of simple reproduction method. A new project, streamlining processes, checking the wrong location.

  • The first step: New two-page fragment, about the distribution, each with a textview examination is normal. Operating normally.
  • Step two: Add a title for the left fragment recyclerview and bring adapters to run normally.
  • Step 3: Add content layout for the right fragment, which reads as follows:
    Here Insert Picture Description
    finally being given, part of the problem found.
  • Step four: Comment component individually, find an error when <view> appears at this time to change the other layouts, such as <LinearLayout> , the problem is solved. Gan said he was.

Conclusion: This error cause is unknown, it takes time 40min, skilled enough, simple reproduction is useful to solve this BUG.

[^ 1] do not know whether.

Published an original article · won praise 1 · views 36

Guess you like

Origin blog.csdn.net/Smooth_re/article/details/105134087