Search code examples
androidfirebaseandroid-studiolintandroid-lint

Lint tags project_id generated by google services plugin as UnusedResource


As described here, the Google Services Plugin generates XML files that can be referenced in code. My problem is that when running the lintRelease task for my Android project, lint tags a resource found in one of the XMLs generated by the said plugin as unused. It incorrectly tags project_id found in build/generated/res/google-services/release/values/values.xml and throws an UnusedResources error. Any idea how to fix this? My lintOptions in my build.gradle look like this:

    lintOptions {
        lintConfig file("${rootDir}/lint.xml")
        baseline file("lint-baseline.xml")
        absolutePaths false
        warningsAsErrors true
        abortOnError true
        checkGeneratedSources true
        ignoreTestSources true
        checkDependencies true
        disable "LintBaseline", "InvalidPackage", "ObsoleteLintCustomCheck", "RtlHardcoded"
    }

My lint.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="InvalidPackage" >
        <ignore path="**/sentry*.jar"/>
    </issue>

    <issue id="all" >
        <ignore path="*/common/testbase"/>
    </issue>

    <issue id="RestrictedApi" severity="error">
        <ignore path="build" />
    </issue>

</lint>

Solution

  • For now I just added the UnusedResources issue on my lint.xml like this:

        <issue id="UnusedResources" severity="error">
            <ignore path="build" />
        </issue>