androidlintandroid-lint

Lint Error UnusedId is shown as false positive when we use view binding


Previously when we were using findViewById, unused resource id is not shown. However, after enabling view binding, an unused resource id is shown inspite of the id used programmatically using generated view binding classes. Now the lint has thrown this as an error rather than a warning which results in a compilation failure. Please find the below error for reference

Error: The resource R.id.showMore appears to be unused [UnusedIds]


Solution

  • As a temporary solution to avoid build error, change the severity of the error to the warning in the lint.xml

    <issue id="UnusedIds" severity="warning"/>