[Feature Request]: Introduce custom Android Lint wrapper & fix key issue categories (GSoC'25 4.3)
Is your feature request related to a problem? Please describe.
The Android build ecosystem supports a linting tool which catches a variety of Android-specific problems (beyond those that can be caught by more general-purpose linters like ktlint). Historically a Gradle feature, Android Lint is not yet directly supported in the Bazel world (though there are some alternatives available). This project involves:
- Introducing an Oppia Android script that runs Android lint directly.
- Supporting the same exemption override support (via XML) but using a textproto interface for parity with the allow-listing and deny-listing configurations used in other Oppia Android scripts.
- Pre-populating the exemption list with existing known failures.
- Adding wiki documentation to explain how to use the new script.
- Filing and/or updating issues with findings such that all remaining Android lint issues are properly tracked in the repository.
- Updating CI to run the Android lint script.
- Fixing the following categories of lint issues:
- All categories classified as 'errors' by the tool.
- All of the following 'warning' categories:
- OldTargetApi
- UnusedAttribute
- Typos
- StringFormatCount
- ObsoleteSdkInt
- UnusedResources
- UselessLeaf
- UselessParent
- UnusedIds
- DuplicateStrings
- SelectableText
- LabelFor
- RtlSymmetry
- UnknownNullness
Describe the solution you'd like
Suggested Milestones:
-
Milestone 1:
- Introduce a new script that can run Android lint checks with support for a local textproto file that can override specific failures to allow them to pass.
- Check in a populated exemption list with all known exemptions.
- Introduce a new wiki page explaining how to use the script and update the exemption list.
- Introduce CI support for the new script so that it runs for every change to develop and for all PRs.
-
Milestone 2:
- Fix all of the error categories of lint issues, plus the warning categories mentioned in the project description.
- Ensure all exemptions that aren't fixed as part of this project have corresponding tracking issues filed and spec'd with enough context for contributors to work on them.
Technical hints / guidance
- General changes explanation:
- Background on running the linter
- Gradle should be running the 'lint' process that's included in the Android cmdline tools (https://developer.android.com/studio#command-tools). A quick dive into that reveals a number of important JARs as part of the classpath:
- tools.lint-model.jar
- tools.lint-checks.jar
- tools.lint-api.jar
- lint-checks-proto.jar
- cli.jar (under lib/lint/cli)
- com.android.tools.lint.Main seems to be the main entrypoint.
- You either need to see if these libraries are published on Maven, or depend on the command line utilities directly (and wrap com.android.tools.lint.Main in the script).
- Note that you can download cmdline tools to inspect the lint command line on its own. Some very important details to note:
- The linter can hang at the end of its process (potentially due to some rogue non-daemon threads). The script will need to work around this limitation.
- It's up to you to analyze how Gradle interacts with the lint tool in order to understand how to construct a valid command line and run the linter. A place to start is a working Gradle run of the linter for reference which can be done following the instructions in this Gist.
- Example reports:
- Important: The files above were produced using lint 4.2.2, but the latest (as of drafting these notes) is 8.2.0.
- You should aim to use the latest compatible version of the lint tool (8.2.0 likely won't work due to requiring JDK 17, but you'll need to check this).
- Furthermore, different versions will have differing results. You should aim to find the most number of issues possible (i.e. configure the tool and its arguments to catch as many problems as it's able to within the codebase).
- Gradle should be running the 'lint' process that's included in the Android cmdline tools (https://developer.android.com/studio#command-tools). A quick dive into that reveals a number of important JARs as part of the classpath:
- The general flow of the script will probably be to process the exemptions proto in order to generate an Android-lint compatible XML exemption file (to pass in), and then run the linter and interpret the results to determine a pass/fail for the overall process.
- The lint tool supports text-based output, XML, and SARIF. It's expected that the script will parse either XML or SARIF formats as they are strongly formatted whereas text may change in future versions of the tool.
- Background on running the linter
- Script changes:
- A new proto message needs to be added in script_exemptions.proto to properly represent exemption failures that are found by Android Lint.
- These exemptions should be designed in a way to ensure that they aren't fragile, i.e. prefer exemption specific categories of failures on a per-file basis rather than per-line. While not perfect, we ultimately aim to reach 0 exemptions in the long-term so per-file is a reasonable stop-gap (we use this approach in other places, though Android lint's exemptions are more elaborate since we need categorical exemptions).
- A new textproto under scripts/assets to contain the new exemptions (all existing failures should be exempted by default before fixes are checked in).
- A new script + tests for wrapping Android lint (no new utilities are expected to be needed at this stage, though it's possible we will need something for interacting with cmdline tools).
- The script will probably need to fail gracefully if it can't locate Android lint, e.g. because cmdline tools wasn't installed, with instructions on how to install it (e.g. using sdkmanager). This should only be necessary if it's not possible to bundle the tool with the script (such as by using the Maven dependency mentioned above).
- Changes to static_checks.sh and static_checks.yml to include the new lint script in each, respectively.
- A new proto message needs to be added in script_exemptions.proto to properly represent exemption failures that are found by Android Lint.
- UI/domain changes:
- Unlikely that there are substantial changes here, but a lot of UI files will require changes as part of addressing the issues of the lint categories mentioned in the project description.
Describe alternatives you've considered
No response
Additional context
No response
Milestone 1
✅ PR 1.1 - #5837
Introduce AndroidLintRunner script to run Lint analysis with minimal configuration
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 02-06-2025 | 04-06-2025 | 06-06-2025 |
Tasks
| Task | Due Date |
|---|---|
| ✅ Setup the Maven libraries and Bazel workspace for script execution | 02-06-2025 |
✅ Introduce AndroidLintRunner script to invoke lint with minimal configuration |
03-06-2025 |
✅ Add tests for executing Lint analysis via AndroidLintRunner script |
04-06-2025 |
⬜ PR 1.2 - #5843
Introduce the LintAnalysisReporter utility to parse XML reports
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 04-06-2025 | 06-06-2025 | 09-06-2025 |
Tasks
| Task | Due Date |
|---|---|
✅ Introduce LintAnalysisReporter to parse and extract XML files |
05-06-2025 |
✅ Add tests to validate XML parsing and extraction in LintAnalysisReporterTest |
06-06-2025 |
⬜ PR 1.3 - #5854
Enhance the LintAnalysisReporter to log reports to the terminal
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 06-06-2025 | 07-06-2025 | 11-06-2025 |
Tasks
| Task | Due Date |
|---|---|
✅ Enhance LintAnalysisReporter to log reports to terminal |
06-06-2025 |
| ✅ Add tests to validate terminal reports | 07-06-2025 |
⬜ PR 1.4 - #5863
Set up lint-test library and Tests for lint tool execution
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 07-06-2025 | 12-06-2025 | 17-06-2025 |
Tasks
| Task | Due Date |
|---|---|
✅ Setup the lint-test library environment in AndroidLintRunnerTest |
07-06-2025 |
| ✅ Add tests for lint tool execution | 12-06-2025 |
⬜ PR 1.5
Introduce the LintProjectDescription utility for Lint configuration
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 12-06-2025 | 19-06-2025 | 24-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Implement in BazelClient to execute Bazel queries for file path collection |
12-06-2025 |
| ⬜ Set project level tags and attributes in XML | 13-06-2025 |
| ⬜ Set module level tags and attributes in XML | 16-06-2025 |
⬜ Add tests to validate Bazel query execution in BazelClientTest |
17-06-2025 |
⬜ Add tests to validate correct project description XML file generation in LintProjectDescriptionTest |
19-06-2025 |
⬜ PR 1.6
Enhance the LintProjectDescription utility to generate XML files for the module
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 19-06-2025 | 24-06-2025 | 29-06-2025 |
Tasks
| Task | Due Date |
|---|---|
| ⬜ Generate module XML file | 19-06-2025 |
| ⬜ Generate Variant XML file | 20-06-2025 |
| ⬜ Generate Dependencies XML file | 21-06-2025 |
| ⬜ Generate Libraries XML file | 22-06-2025 |
⬜ Add tests to validate correct XML files generation in LintProjectDescriptionTest |
24-06-2025 |
⬜ PR 1.7
Enhance the AndroidLintRunner script to generate reports with finalized configurations
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 24-06-2025 | 27-06-2025 | 30-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Hook utilities to AndroidLintRunner to generate reports |
24-06-2025 |
⬜ Add tests to validate accuracy of the script in AndroidLintRunnerTest |
27-06-2025 |
⬜ PR 1.8
Enhance LintAnalysisReporter for exemption support
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 27-06-2025 | 30-06-2025 | 02-07-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Set exemption message format and Enum list in script_exemptions.proto |
27-06-2025 |
⬜ Populate issues in android_lint_exemptions.textproto |
28-06-2025 |
⬜ Enhance LintAnalysisReporter to load exemptions from the textproto file |
29-06-2025 |
| ⬜ Add tests to validate exemption of issues in reports | 30-06-2025 |
⬜ PR 1.9
Enhance static_checks for CI integration of script
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 30-06-2025 | 01-07-2025 | 02-07-2025 |
⬜ PR 1.10
Create Wiki for Android Lint Analysis script
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 02-07-2025 | 03-07-2025 | 04-07-2025 |
⬜ PR 1.11
Resolve issues with severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 03-07-2025 | 03-07-2025 | 04-07-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UseAppTint |
03-07-2025 |
⬜ Resolve the issue category UseRequireInsteadOfGet |
03-07-2025 |
| ⬜ Add relevant tests for code changes | 03-07-2025 |
Milestone 2
⬜ PR 2.1
Resolve Lint issue category NewApi of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 26-07-2025 | 28-07-2025 | 31-07-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category NewApi |
27-07-2025 |
| ⬜ Add relevant tests for code changes | 28-07-2025 |
⬜ PR 2.2
Resolve Lint issue category InvalidFragmentVersionForActivityResult of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 28-07-2025 | 01-08-2025 | 04-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category InvalidFragmentVersionForActivityResult |
31-07-2025 |
| ⬜ Add relevant tests for code changes | 01-08-2025 |
⬜ PR 2.3
Resolve Lint issue category MissingClass of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 01-08-2025 | 05-08-2025 | 08-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category MissingClass |
04-08-2025 |
| ⬜ Add relevant tests for code changes | 05-08-2025 |
⬜ PR 2.4
Resolve Lint issue category UnusedResources of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 05-08-2025 | 08-08-2025 | 12-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedResources |
07-08-2025 |
| ⬜ Add relevant tests for code changes | 08-08-2025 |
⬜ PR 2.5
Resolve Lint issue category DuplicateStrings of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 08-08-2025 | 10-08-2025 | 13-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category DuplicateStrings |
09-08-2025 |
| ⬜ Add relevant tests for code changes | 10-08-2025 |
⬜ PR 2.6
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 10-08-2025 | 13-08-2025 | 16-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category SelectableText |
12-08-2025 |
⬜ Resolve the issue category UnknownNullness |
12-08-2025 |
| ⬜ Add relevant tests for code changes | 13-08-2025 |
⬜ PR 2.7
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 13-08-2025 | 15-08-2025 | 18-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedAttribute |
13-08-2025 |
⬜ Resolve the issue category LabelFor |
13-08-2025 |
⬜ Resolve the issue category StringFormatCount |
14-08-2025 |
| ⬜ Add relevant tests for code changes | 15-08-2025 |
⬜ PR 2.8
Resolve Lint issue category OldTargetApi of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 15-08-2025 | 21-08-2025 | 25-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category OldTargetApi |
20-08-2025 |
| ⬜ Add relevant tests for code changes | 21-08-2025 |
⬜ PR 2.9
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 21-08-2025 | 23-08-2025 | 26-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedIds |
21-08-2025 |
⬜ Resolve the issue category Typos |
21-08-2025 |
⬜ Resolve the issue category RtlSymmetry |
21-08-2025 |
⬜ Resolve the issue category UselessParent |
22-08-2025 |
| ⬜ Add relevant tests for code changes | 23-08-2025 |
⬜ PR 2.10
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 23-08-2025 | 25-08-2025 | 27-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UselessLeaf |
23-08-2025 |
⬜ Resolve the issue category ObsoleteSdkInt |
24-08-2025 |
| ⬜ Add relevant tests for code changes | 25-08-2025 |
Meeting Minutes: [Link to Doc]
Weekly Journal: [Link to Journal]
Milestone 1
⬜ PR 1.1
Introduce AndroidLintRunner script to run Lint analysis with minimal configuration
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 02-06-2025 | 04-06-2025 | 06-06-2025 |
Tasks
| Task | Due Date |
|---|---|
| ⬜ Setup the Maven libraries and Bazel workspace for script execution | 02-06-2025 |
⬜ Introduce AndroidLintRunner script to invoke lint with minimal configuration |
03-06-2025 |
⬜ Add tests for executing Lint analysis via AndroidLintRunner script |
04-06-2025 |
⬜ PR 1.2
Introduce the LintAnalysisReporter utility to parse XML reports
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 04-06-2025 | 06-06-2025 | 09-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Introduce LintAnalysisReporter to parse and extract XML files |
05-06-2025 |
⬜ Add tests to validate XML parsing and extraction in LintAnalysisReporterTest |
06-06-2025 |
⬜ PR 1.3
Enhance the LintAnalysisReporter to log reports to terminal
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 06-06-2025 | 08-06-2025 | 11-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Enhance LintAnalysisReporter to log reports to terminal |
06-06-2025 |
⬜ Setup the lint-test library environment in AndroidLintRunnerTest |
08-06-2025 |
⬜ PR 1.4
Introduce the LintProjectDescription utility for Lint configuration
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 08-06-2025 | 19-06-2025 | 24-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Implement in BazelClient to execute Bazel queries for file path collection |
10-06-2025 |
| ⬜ Set project level tags and attributes in XML | 13-06-2025 |
| ⬜ Set module level tags and attributes in XML | 17-06-2025 |
⬜ Add tests to validate Bazel query execution in BazelClientTest |
18-06-2025 |
⬜ Add tests to validate correct project description XML file generation in LintProjectDescriptionTest |
19-06-2025 |
⬜ PR 1.5
Enhance the AndroidLintRunner script to generate reports with finalized configurations
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 19-06-2025 | 23-06-2025 | 27-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Hook utilities to AndroidLintRunner to generate reports |
19-06-2025 |
⬜ Add tests to validate accuracy of the script in AndroidLintRunnerTest |
23-06-2025 |
⬜ PR 1.6
Enhance LintAnalysisReporter for exemption support
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 23-06-2025 | 25-06-2025 | 28-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Set exemption message format and Enum list in script_exemptions.proto |
23-06-2025 |
⬜ Populate issues in android_lint_exemptions.textproto |
23-06-2025 |
⬜ Enhance LintAnalysisReporter to load exemptions from the textproto file |
24-06-2025 |
| ⬜ Add tests to validate exemption of issues in reports | 25-06-2025 |
⬜ PR 1.7
Enhance static_checks for CI integration of script
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 25-06-2025 | 26-06-2025 | 28-06-2025 |
⬜ PR 1.8
Create Wiki for Android Lint Analysis script
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 26-06-2025 | 27-06-2025 | 29-06-2025 |
⬜ PR 1.9
Resolve issues with severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 27-06-2025 | 28-06-2025 | 30-06-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UseAppTint |
27-06-2025 |
⬜ Resolve the issue category UseRequireInsteadOfGet |
28-06-2025 |
| ⬜ Add relevant tests for code changes | 28-06-2025 |
Buffer Time
To work on reviews and code changes.
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 28-06-2025 | 30-06-2025 | 04-07-2025 |
Milestone 2
⬜ PR 2.1
Resolve Lint issue category NewApi of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 26-07-2025 | 28-07-2025 | 31-07-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category NewApi |
27-07-2025 |
| ⬜ Add relevant tests for code changes | 28-07-2025 |
⬜ PR 2.2
Resolve Lint issue category InvalidFragmentVersionForActivityResult of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 28-07-2025 | 01-08-2025 | 04-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category InvalidFragmentVersionForActivityResult |
31-07-2025 |
| ⬜ Add relevant tests for code changes | 01-08-2025 |
⬜ PR 2.3
Resolve Lint issue category MissingClass of severity ‘Error’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 01-08-2025 | 05-08-2025 | 08-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category MissingClass |
04-08-2025 |
| ⬜ Add relevant tests for code changes | 05-08-2025 |
⬜ PR 2.4
Resolve Lint issue category UnusedResources of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 05-08-2025 | 08-08-2025 | 12-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedResources |
07-08-2025 |
| ⬜ Add relevant tests for code changes | 08-08-2025 |
⬜ PR 2.5
Resolve Lint issue category DuplicateStrings of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 08-08-2025 | 10-08-2025 | 13-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category DuplicateStrings |
09-08-2025 |
| ⬜ Add relevant tests for code changes | 10-08-2025 |
⬜ PR 2.6
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 10-08-2025 | 13-08-2025 | 16-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category SelectableText |
12-08-2025 |
⬜ Resolve the issue category UnknownNullness |
12-08-2025 |
| ⬜ Add relevant tests for code changes | 13-08-2025 |
⬜ PR 2.7
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 13-08-2025 | 15-08-2025 | 18-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedAttribute |
13-08-2025 |
⬜ Resolve the issue category LabelFor |
13-08-2025 |
⬜ Resolve the issue category StringFormatCount |
14-08-2025 |
| ⬜ Add relevant tests for code changes | 15-08-2025 |
⬜ PR 2.8
Resolve Lint issue category OldTargetApi of severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 15-08-2025 | 21-08-2025 | 25-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category OldTargetApi |
20-08-2025 |
| ⬜ Add relevant tests for code changes | 21-08-2025 |
⬜ PR 2.9
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 21-08-2025 | 23-08-2025 | 26-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UnusedIds |
21-08-2025 |
⬜ Resolve the issue category Typos |
21-08-2025 |
⬜ Resolve the issue category RtlSymmetry |
21-08-2025 |
⬜ Resolve the issue category UselessParent |
22-08-2025 |
| ⬜ Add relevant tests for code changes | 23-08-2025 |
⬜ PR 2.10
Resolve issues with severity ‘Warning’
| Starting Date | Creation Date | Merge Date |
|---|---|---|
| 23-08-2025 | 25-08-2025 | 27-08-2025 |
Tasks
| Task | Due Date |
|---|---|
⬜ Resolve the issue category UselessLeaf |
23-08-2025 |
⬜ Resolve the issue category ObsoleteSdkInt |
24-08-2025 |
| ⬜ Add relevant tests for code changes | 25-08-2025 |
Hi @manas-yu, could you please add the milestone table directly to the PR description? It’ll help ensure it doesn’t get lost in the thread as the conversation grows. Thanks!
Hi @Nik-09 i have updated the description PTAL. Thanks!
Thanks @manas-yu looks good