Importing Android Lint issues in multi module project with checkDependencies enabled

  • Sonar Developer Edition v2025.1.3 (110580)
  • Sonar Gradle Plugin 6.3.1.5724
  • Android Gradle Plugin 8.12.2

I’m trying to follow the advice from https://googlesamples.github.io/android-custom-lint-rules/user-guide.md.html#performancetuning/onlyanalyzeapp/leafmodules

If you have divided your project into many smaller modules — a number of libraries and just a couple of app modules — it’s much better to

  1. Turn on checkDependencies mode, and

  2. Only run lint on the app modules, instead of recursively running lint on each module.

To do this, first add this to your app module’s build.gradle file:

android {
    ...
    lintOptions {
        ...
        checkDependencies true
        ...
    }
}

Then instead of running ./gradlew lintDebug, run ./gradlew :app:lintDebug.

Since you’ve turned on check-dependencies mode, running lint on the app module will also run it on all the dependent modules the app depends on — e.g. all the libraries.

So I configured Sonar to import the reports from app modules instead of library modules:

subprojects { subproject ->
    plugins.withId("com.android.application") {
        sonarqube {
            properties {
                property "sonar.androidLint.reportPaths", ["build/reports/lint-results-prodLocalDebug.xml"]
            }
        }
    }

But I don’t see issues from library modules in Sonar panel anymore. And I see some warnings in the logs such as:

Importing <PROJECT_PATH>/app/build/reports/lint-results-prodLocalDebug.xml
No input file found for <PROJECT_PATH>/lib-core/src/main/AndroidManifest.xml. No android lint issues will be imported on this file.

Is it possible to configure Sonar gradle plugin so that it works fine with checkDependencies true for Android Lint?

The only sensible way to do it that I came up with so far that looks promising is to run Lint on only one app module (can’t run it on more than one, because that results in duplicate issues) and specify report path from that app module as sonar.androidLint.reportPaths in all other modules… :thinking:

So my “solution” is basically the same as Giuseppe’s here How to setup a single Android Lint report in a multi-module Android project

But it has the same problem that there are lots of warnings:

No input file found for file_path. No android lint issues will be imported on this file.

for the issues that are reported on modules other than the one currently being imported by Sonar.

Which may be a minor issue, but it suggests that integration between the two tools does not fit very well. And potentially causes some other problems I’m not aware about?

(answer from the other topic, about relative paths, can be ignored because those simply don’t work, and even if they did, they wouldn’t change anything)