-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] merge two targets to fix AndroidX.Migra…
…tion (#4151) Context: https://github.com/xamarin/XamarinAndroidXMigration Fixes: #4068 Developers have been reporting an error when using AndroidX.Migration: The "CopyGeneratedJavaResourceClasses" task was not given a value for the required parameter "SourceTopDirectory". It is reported another build fixes the issue, and it "randomly" happens on incremental builds. The error seems to indicate either `$(AaptTemporaryDirectory)` or `$(ResgenTemporaryDirectory)` are blank? But it only happens when using the AndroidX.Migration NuGet package. From a user's build log: Skipping target "_PrepareCreateBaseApk" because all output files are up-to-date with respect to the input files. Which would indicate in the case of AndroidX.Migration: * `_PrepareCreateBaseApk` was skipped. * `_AndroidXJetifyManifest` was injected, it came along and modified `$(IntermediateOutputPath)android\AndroidManifest.xml`. * `_CreateBaseApk` ran (with updated inputs), and `$(AaptTemporaryDirectory)` is blank! I could reproduce the problem in a test: * Build a project with AndroidX.Migration * Change C# code (a non-Java.Lang.Object class) * Build the project again Reviewing the MSBuild targets: `_PrepareCreateBaseApk` and `_CreateBaseApk`. They define a property that is passed between two targets. The following sets of targets have nearly identical `Input`/`Output`: * `_PrepareCreateBaseApk` and `_CreateBaseApk` * `_PrepareUpdateAndroidResgen` and `_UpdateAndroidResgen` This was done to workaround a long-lived bug in MSBuild: dotnet/msbuild#1006 A fix that doesn't seem break anything is to just run `_PrepareCreateBaseApk` *after* `$(AfterGenerateAndroidManifest)`. So if something triggers `_CreateBaseApk`, `_PrepareCreateBaseApk` will always run as well. I wrote a test for this scenario, and updated the AndroidX NuGets in our tests to use the RC now.
- Loading branch information
1 parent
4e389c4
commit 4a17303
Showing
4 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters