Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] reorder two targets to fix AndroidX.Migration #4151

Merged
merged 1 commit into from
Jan 22, 2020

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Jan 21, 2020

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.

…tion

Context: https://github.com/xamarin/XamarinAndroidXMigration
Fixes: dotnet#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.
@jonathanpeppers jonathanpeppers changed the title [Xamarin.Android.Build.Tasks] merge two targets to fix AndroidX.Migration [Xamarin.Android.Build.Tasks] reorder two targets to fix AndroidX.Migration Jan 21, 2020
@dellis1972 dellis1972 merged commit 4a17303 into dotnet:master Jan 22, 2020
@mattleibow
Copy link
Member

Sorry about not reviewing. I though I hit the submit button. Looked good to me.

@jonathanpeppers jonathanpeppers deleted the androidxmigrationbug branch January 22, 2020 16:08
jonpryor pushed a commit that referenced this pull request Jan 27, 2020
…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.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants