Android.view.InflateException:Binary XML file line #16: Error&nbs

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/huangxiaohu_coder/article/details/8497286

In the native Android to compile the APK, compile no problem, but at run time often appear as described in the title of the exception, and then the whole program crash off ...

I have encountered this problem often because of the modification of the resource files caused by, roughly the following several ways to solve:

1. Referencing a class name problem: Customizing a view to use in a layout file, assuming that his package is named MyPackage, the class name is Mytestview, and this time you are laying out XML as a layout element, you must use the full pathname, which is the package name plus the class name to refer to, Use Mypackage.mytestview to make references.

2. Constructor problem: To customize a view, you must derive the three constructors that implement the base class View

View (context context)//simple constructor to use where creating a view from code

View (context context, AttributeSet Attrs)//constructor that's called when inflating a view from XML

View (context context, AttributeSet attrs, int defstyle)//perform inflation from XML and apply a class-specific base s Tyle

From the introduction of the document, the second and third constructors have to be implemented for XML, and these three constructors should be used to instantiate a view object in different contexts.

3. Compiled intermediate files are not cleaned up: The third is you in the native system code compiled environment after the APK, especially modified XML, the title of the phenomenon described, this time you just need to delete the out directory compiled generated intermediate folder can be (the name is not clear: in the compilation process, The system will print that location, through the serial port to see it, .../out/....../..../classes.dex, you follow this path forward to your app's project name that layer folder), delete and re-make is OK.

4. Resource file not found: I originally in 2.3 of the native system to add live wallpaper, live wallpaper a run up on this anomaly, and then crash, then was because the drawable resource file was not found, so then I put drawable hdpi or NODPI and other folders of the picture resources are copied to the drawble, the problem solved (at that time did not understand the system will be based on the resolution to choose to load different drawable folder resources, why must be placed in drawable).

Android.view.InflateException:Binary XML file line #16: Error&nbs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.