Search code examples
androidandroid-sdk-toolsandroid-lint

How do I run standalone lint from Android SDK Tools on a Gradle Project


When I try to run the lint tool provided in the Android SDK Command Line tools, it fails with the following error

build.gradle: Error: "." is a Gradle project. To correctly analyze Gradle projects, you should run "gradlew lint" instead. [LintError]
1 errors, 0 warnings

My use case requires me to run the standalone lint in a CI environment with specific checks. How do I get around this error?


Solution

  • I searched around for documentation and answers. Documentation doesn't have much information on the topic. I had found one answer before posting this question but the provided suggestions around the error didn't work either. In the end, as Chester said, it didn't even matter.

    Since I am running the tool in a CI environment, I ended up doing the following

    # delete the build.gradle files from the project
    find . -type f -name "build.gradle" -exec rm -f {} \;
    
    # run the lint with whatever checks. It works!!
    lint --check Whatever .
    
    # stash everything except the deleted files
    git add **/*/build.gradle
    git stash -k
    
    # stash the deleted files
    git stash
    
    # drop the stash with deleted files
    git stash drop
    
    # pop the stash with everything else
    git stash pop
    

    It's a dirty hack. Always open to better solutions!