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

Incremental build issue when adding Android resource #9588

Closed
jpobst opened this issue Dec 4, 2024 · 2 comments · Fixed by #9592
Closed

Incremental build issue when adding Android resource #9588

jpobst opened this issue Dec 4, 2024 · 2 comments · Fixed by #9592
Assignees
Labels
Area: Android Resources Issues with Android Resources (aapt, etc) Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@jpobst
Copy link
Contributor

jpobst commented Dec 4, 2024

Android framework version

net9.0-android

Affected platform version

.NET 9.0.101

Description

Adding a new Android resource to a project causes the incremental build to error with:

Resources\layout\activity_two.xml error APT2126: file not found.

This error comes from the Aapt2Compile task. It is looking for \obj\Debug\net9.0-android\res\layout\activity_two.xml but that file doesn't exist. Presumably some previous incremental step is not running and copying it there?

binlog.zip

Steps to Reproduce

dotnet new android
dotnet build -bl
copy Resources\layout\activity_main.xml Resources\layout\activity_two.xml
dotnet build -bl
@jpobst jpobst added Area: App+Library Build Issues when building Library projects or Application projects. needs-triage Issues that need to be assigned. labels Dec 4, 2024
@jpobst jpobst added Area: Android Resources Issues with Android Resources (aapt, etc) and removed needs-triage Issues that need to be assigned. labels Dec 4, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Dec 4, 2024
@jpobst jpobst removed the needs-triage Issues that need to be assigned. label Dec 4, 2024
@jpobst
Copy link
Contributor Author

jpobst commented Dec 4, 2024

This appears to be because the copied resource does not have an updated "last modified date", thus some earlier target isn't running.

The target needs to check if resource(s) were added/removed as well as "last modified date".

@dellis1972
Copy link
Contributor

Yes, this is a modified date issue. the new file has a modified date time earlier than the obj\Debug\net9.0-android\res.flag.
So _GenerateAndroidResourceDir is skipped.
I'll add a check for file hashes.

dellis1972 added a commit that referenced this issue Dec 7, 2024
Fixes #9588

Adding a new Android resource to a project causes the incremental build to error with:
```
Resources\layout\activity_two.xml error APT2126: file not found.
```
This error comes from the `Aapt2Compile` task. It is looking for `\obj\Debug\net9.0-android\res\layout\activity_two.xml` but that file doesn't exist.

What was happening is the new file had the same modified date as the flag/stamp file that was used to generate it.
The user was using `copy Resources\layout\activity_main.xml Resources\layout\activity_two.xml`. So the modified date was not "new". This caused the _GenerateAndroidResourceDir target to get skipped.

What we should do is copy what we do in other places, and hash all the input files (and their destinations) into one hash.
We can then use that hash file as an input to the target. This allows us to detect when a new file is added, even if it has an old timestamp.

A unit test was added as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Android Resources Issues with Android Resources (aapt, etc) Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants