NoSuchFieldError on findViewById() NoSuchFieldError on findViewById() android android

NoSuchFieldError on findViewById()


I had the same error and it turns out that the resource was overridden.

If you have one project working as a library that declares some id in a given XML file,then your main project redefines that XML, the original id is gone, but you won't see the error until run time.

In my case, a partner deleted and committed the XML from the project, then added it back in the library project. Subclipse didn't seems to notice that because I was up to date, but the XML was there on the main project.


Well, I am Chinese. My English is not good.

I got the question too.

The solution may be:The name of xml file is repeated, eg:a.xml is in your library project, at the same time, a.xml is in your main project. so, please change one of the xml name.


To elaborate on @Moxor's solution, you can either:

  1. Decalare a dummy layout xml, and assign the missing ids to some dummy Views.
  2. Declare the missing ids as resources, the same way you declare a string resource: http://developer.android.com/guide/topics/resources/more-resources.html#Id