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. the compiled intermediate file is not clean: the third is that you compile the original system code in the compilation environment after the APK, especially the modification of the XML, the title of the phenomenon, this time you just need to delete the Out directory compilation generated intermediate folder can be (the name is not clear: in the compilation process , the system will print out 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 Runtime exception "Binary XML file Line #: Error inflating Class"