'Android: Lint says - Class referenced in the layout file, was not found in the project or the libraries

In my app, I am using Pull TO Refresh list view library. I had designed layouts for all screens respectively. When I ran lint on my project, in one of my layout file for xlarge screen, it gave me fatal error:

Class referenced in the layout file, com.handmark.pulltorefresh.library.PullToRefreshListView, was not found in the project or the libraries

While in same layout file for other screens, it is giving no error at all. Also, I had used same library in other layouts of my file, where it does not give any error. It is giving same error for Google Maps api as well. My project targets Google Api level 16 and I had checked, all libraries are added to it. But,the error doesn't go away even on cleaning project.



Solution 1:[1]

This is a lint bug and you can safely ignore it. Lint is meant to help, not to hinder your development time. Change the lint Errors to warnings and you can compile and run the app just fine. I don't recommend turning it off because it helps to keep your code cleaner.

Solution 2:[2]

Make a project Project -> Clean... this resets the bug errors for me.

Solution 3:[3]

I was also getting a similar error, for me, it was resolved by adding android.enableJetifier=true to gradle.properties.

Solution 4:[4]

You can suppress the lint error by, passing the error type to the ignore attribute within that view, for example:

<com.handmark.pulltorefresh.library.PullToRefreshListView
    ...
    tools:ignore="MissingClass"
    ...
/>

Just make sure you have tools imported:

xmlns:tools="http://schemas.android.com/tools"

References:

https://googlesamples.github.io/android-custom-lint-rules/checks/MissingClass.md.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 mbauer
Solution 3 Abdul Wadood
Solution 4 Anthony Cannon