Repository navigation
[Xamarin.Android.Build.Tasks] Remove Android lint support - #13592
Conversation
$(AndroidLintEnabled) ran the Android lint tool on generated files in obj/. It was off by default and its output did not point to the original source. Remove the Lint task, the _LintChecks target, the lint properties, the @(AndroidLintConfig) item, and LintToolPath resolution. Repurpose XA0108 as a warning when $(AndroidLintEnabled) is true, and remove XA0102, XA0103, XA0123, and XA5205_Lint. Co-authored-by: Copilot App <[email protected]>
Build a default app, then run the Android SDK lint tool on the generated files in obj/. The test disables the checks that fire today and fails on any new lint issue. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
ResolveSdks.CommandLineToolsPath only set _AndroidToolsDirectory, which nothing reads. Remove it, the AndroidCommandLineToolsVersion SDK input, and the MonoAndroidHelper.Shared.cs link that only Lint needed. Use lint --exitcode -Werror in the test and shorten the XA0108 text. Co-authored-by: Copilot App <[email protected]>
Keep the XA0102 and XA0103 pages marked as retired, like #13407 did. Disable OldTargetApi in the lint test, because newer installed platforms trigger it. Restore end-to-end escaping coverage with ZipAlignToolPath. Remove the fake lint file from test SDKs and the unused environment parameter of MonoAndroidHelper.RunProcess (). Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Reusing the XA0108 resource key causes localized builds to display the obsolete lint-version warning instead of removal guidance, so the new message needs a distinct resource key.
1 open issue
1 file not reviewed
src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
What changed in this PR
Removes built-in Android lint support from the .NET for Android build pipeline rather than replacing it with MSBuild targets as proposed in #13500. Users can run the Android SDK lint tool directly.
Changes:
- Removes the lint task, build integration, tool discovery, and obsolete resources.
- Adds an XA0108 compatibility warning and documents the removed settings.
- Replaces lint integration tests with a direct lint check of generated files and updates tooling-reuse tests.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Tooling.targets | Removes command-line tool resolution and forwarding. |
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Removes lint integration and adds the compatibility warning. |
| src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.Shared.cs | Removes lint-only environment overrides. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidItem.cs | Removes the lint configuration item wrapper. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidBuildActions.cs | Removes the lint build-action constant. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs | Uses zipalign paths in tooling-forwarding tests. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs | Supports test process environments and removes fake lint. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ResolveSdksTaskTests.cs | Updates SDK tests for removed lint outputs. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs | Adds direct lint validation and checks XA0108. |
| src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs | Removes unused command-line tool properties. |
| src/Xamarin.Android.Build.Tasks/Tasks/ResolveAndroidTooling.cs | Removes lint discovery. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Updates XA0108 and removes obsolete lint messages. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Synchronizes resource accessors and comments. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets | Removes the lint configuration build action. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Tooling.targets | Removes lint inputs, outputs, and forwarding. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets | Removes lint from packaging order. |
| src/Microsoft.Android.Build.Tasks/Tests/Microsoft.Android.Build.Tasks.Tests/Tasks/LintTests.cs | Deletes lint task unit tests. |
| src/Microsoft.Android.Build.Tasks/Tasks/Lint.cs | Deletes the lint task implementation. |
| src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj | Removes the lint-only shared-source link. |
| src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics/Diagnostic.cs | Removes retired lint diagnostic comments. |
| Documentation/docs-mobile/messages/xa5205.md | Removes the missing-lint example. |
| Documentation/docs-mobile/messages/xa0108.md | Documents the removal warning and migration guidance. |
| Documentation/docs-mobile/messages/xa0103.md | Marks the lint error as retired. |
| Documentation/docs-mobile/messages/xa0102.md | Marks the lint warning as retired. |
| Documentation/docs-mobile/messages/index.md | Updates diagnostic listings and removes the lint task prefix. |
| Documentation/docs-mobile/building-apps/build-properties.md | Marks lint properties as removed in .NET 12. |
| Documentation/docs-mobile/building-apps/build-items.md | Marks AndroidLintConfig as removed in .NET 12. |
Review effort: Balanced
…e-lint-support # Conflicts: # src/Microsoft.Android.Build.Tasks/Microsoft.Android.Build.Tasks.csproj # src/Xamarin.Android.Build.Tasks/Tasks/ResolveSdksTask.cs
The localized .resx files still have the old XA0108 text. A new key makes untranslated cultures fall back to the English message. The diagnostic code stays XA0108. Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 1d4a58ad against main at 14dd230f (merge-base 1c2fe6dc, 28 files). This is a static, read-only review; I did not build or run tests.
Within its own diff the lint removal is complete. Nothing outside the retired docs and generated localization files still references the removed task, properties, item or targets. The new XA0108_LintEnabled resource key fixes the earlier localization concern, and the warning sits in the app-only _CheckNonIdealAppConfigurations like the old _LintChecks did.
Two blockers:
- Microsoft.Android.Build.Tasks no longer compiles once this merges with current
main. #13515 (now onmain) movedAapt2into Microsoft.Android.Build.Tasks, andsrc/Microsoft.Android.Build.Tasks/Tasks/Aapt2.cs:26and:169callMonoAndroidHelper.ItemGroupToCaseMapandMonoAndroidHelper.FixUpAndroidResourcePath. Both are defined only inMonoAndroidHelper.Shared.cs. This PR deletes that file's compile link fromMicrosoft.Android.Build.Tasks.csproj(lines 89-90 onmain). The hunks don't overlap, so git merges cleanly and the build then fails with CS0117. Please mergemainand keep theMonoAndroidHelper.Shared.cslink, rewording its comment to say Aapt2 needs it, or move those two helpers into a file that's already linked. external/android-api-docsis rolled back. The PR moves the submodule fromb6c8521e(set onmainby #13588) back to9aeed911, which is 86 commits behind. The earlier merge frommain(390c772f57) kept the branch's older pointer, so merging this would silently undo #13588. Please reset it to main's pointer (for examplegit checkout origin/main -- external/android-api-docs) so it drops out of the diff.
Minor and non-blocking: Resources.Designer.cs loses its UTF-8 BOM on line 1.
Aapt2 moved into Microsoft.Android.Build.Tasks (#13515) and uses ItemGroupToCaseMap () and FixUpAndroidResourcePath (), so keep the link. Reset external/android-api-docs to the commit on main, and restore the UTF-8 BOM in Resources.Designer.cs. Co-authored-by: Copilot App <[email protected]>
The rebase onto cc7cbf6 kept the pre-rebase MSTest conversions of files that main had changed since aa688ac, which reverted those changes and broke the build. For each affected file, convert main's old and new NUnit versions with the same converter and merge the difference into the MSTest file: * cca255c (#13592): drop the Android lint tests and assertions. * 5b32fb1 (#13602): add RelativeDirectoriesUseProjectDirectory and the -mt CollectNonEmptyDirectories coverage. * 78ef747 (#13655): add OpenGenericProxiesKeepTheReflectionActivationConstructor. * 18b8940 (#13585): add the generator nullability/obsolete tests. * dcbd008 (#13580): add the AmbiguousFunctionMetadata_* tests. * 667e27a (#13621): add the sdkmanager package ID tests. * 5ecb8f7 (#13614): drop RunWithLoggingEnablesManagedTimingLogger. * 8287b17 (#13680), 4bfcc92 (#13681): restore the re-enabled tests and removed TODOs. * 5d81a0f (#13666): expect platform-tools 37.0.3. * 8442c75 (#13601): assert the pulled device TRX is deleted. Also drop the EnableNUnitRunner/OutputType lines that 857f463 (#13563) added to Xamarin.Android.Build.Tests and MSBuildDeviceIntegration; MSTestReferences.projitems sets both. Co-authored-by: Copilot App <[email protected]>

Context: #13500
$(AndroidLintEnabled)ran the Android SDKlinttool on the generated files inobj/during packaging. It was off by default, its results pointed at intermediate files instead of the project's sources, and anyone who wantslintcan run it from the Android SDKcmdline-toolsdirectly. #13500 proposed rewriting the<Lint/>task as MSBuild targets; removing the feature is less code to maintain.Removed
<Lint/>task, its unit tests, and the_LintCheckstarget$(AndroidLintEnabledIssues),$(AndroidLintDisabledIssues),$(AndroidLintCheckIssues),$(LintToolPath), and the@(AndroidLintConfig)itemlintdiscovery in<ResolveAndroidTooling/>and its forwarding to inner buildsResolveSdks.CommandLineToolsPath, which only set$(_AndroidToolsDirectory); nothing read that propertyCompatibility
XA0108 now warns when an app sets
$(AndroidLintEnabled)totrue:The docs for the removed properties and item stay and say they were removed in .NET 12.
Tests
AndroidLintHasNoNewIssuesreplaces the three lint integration tests. It builds a default app, checks for XA0108, then runslint --exitcode -Werrorfromcmdline-toolson the generated manifest, resources, and Java sources. The five checks that fire today (CustomX509TrustManager,HardcodedDebugMode,MissingApplicationIcon,RedundantLabel,UnusedResources) are disabled, so any newlintissue in generated files fails the test.The tooling-reuse tests used
$(LintToolPath)as an escaped path; they now use$(ZipAlignToolPath).Validation
Built the local SDK on Windows (
dotnet-local.cmd build Microsoft.Android.slnx,-t:BuildExtraApiLevels,-t:ConfigureLocalWorkload), then:40 passed, 0 failed.
Microsoft.Android.Build.Tasks.Testsbuilds.