Recently in the porting of doing a project. Directly changed the application of the theme, the least careful inspection. Results applications are crash directly in some scenarios. Fortunately, by using log, you can see that an error occurred while inflate a resource. Locate the corresponding XML file by locating the ID of the resource, and find that the suspect is that ImageView uses a Theme attribute "? Xxxattr".
XXXATTR is defined as a property of type "reference", but does not point to a specific resource for xxxattr in theme. In the perspective of C language, Xxxattr is the pointer, the resource specified for xxxattr in theme is the specific content that the pointer points to. Because the pointer does exist, there is no error when compiling, but at run time, the run-time error occurs because the pointer is empty. Therefore, it is important to pay attention to this type of problem when using theme attributes.
Think: If you can set a default resource for a property when defining a property, you won't get the problem, why doesn't Google think about it?