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] Fix aapt_rules.txt corruption #7587

Merged
merged 3 commits into from
Dec 12, 2022

Conversation

dellis1972
Copy link
Contributor

Fixes #7447

Users are reporting a error with the aapt_rules file generated by aapt2

MSBUILD : java.exe error JAVA0000: Error in obj\Release\110\aapt_rules.txt at line 289, column 1: [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: Expected char '-' at obj\Release\110\aapt_rules.txt:289:1 [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: nit>(...); } [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: Compilation failed

This only happens when building with AndroidCreatePackagePerAbi set to true. After looking at the code, it turns out that we call aapt2 link multiple times when building per abi. The temp file used for the aapt2 link proguard output was the same file for ALL of the calls. This results in one call to aapt2 overwriting the previous ones results... or worse leaving garbage at the end.

So the fix in this case is to provide a different temp file for each call to aapt2. These files are then combined later just in case they contain unique information for that abi. While this does result in duplicate lines in the aapt_rules file, this does not impact on the build.

@dellis1972 dellis1972 force-pushed the Issue7447 branch 2 times, most recently from 58b0278 to 4623e8a Compare December 1, 2022 14:20
@dellis1972 dellis1972 marked this pull request as ready for review December 2, 2022 16:49
@dellis1972 dellis1972 requested a review from jonpryor December 2, 2022 16:49
Fixes dotnet#7447

Users are reporting a error with the aapt_rules file generated by aapt2
```
MSBUILD : java.exe error JAVA0000: Error in obj\Release\110\aapt_rules.txt at line 289, column 1: [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: Expected char '-' at obj\Release\110\aapt_rules.txt:289:1 [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: nit>(...); } [C:\Jenkins\workspace\Demo\Demo.Android\Demo.Android.csproj]
MSBUILD : java.exe error JAVA0000: Compilation failed
```

This only happens when building with `AndroidCreatePackagePerAbi` set
to `true`. After looking at the code, it turns out that we call
`aapt2 link` multiple times when building per abi. The temp file used
for the `aapt2 link` proguard output was the same file for ALL of the
calls. This results in one call to aapt2 overwriting the previous ones
results... or worse leaving garbage at the end.

So the fix in this case is to provide a different temp file for each
call to `aapt2`. These files are then combined later just in case they
contain unique information for that abi. While this does result in
duplicate lines in the `aapt_rules` file, this does not impact on the
build.
@dellis1972 dellis1972 requested a review from jonpryor December 8, 2022 10:21
@jonpryor jonpryor merged commit 6383b4e into dotnet:main Dec 12, 2022
@dellis1972 dellis1972 deleted the Issue7447 branch December 12, 2022 20:26
grendello added a commit to grendello/xamarin-android that referenced this pull request Jan 4, 2023
* main:
  [Xamarin.Android.Build.Tasks] use %(TrimmerRootAssembly.RootMode) All (dotnet#7651)
  Bump to dotnet/installer@47a747f 8.0.100-alpha.1.22616.7 (dotnet#7647)
  Bump to dotnet/installer@167a4ed 8.0.100-alpha.1.22611.1 (dotnet#7630)
  Bump to xamarin/Java.Interop/main@f8d77fa (dotnet#7638)
  [ci] Fix Designer test paths (dotnet#7635)
  [Xamarin.Android.Build.Tasks] perf improvements for LlvmIrGenerator (dotnet#7626)
  [Xamarin.Android.Build.Tasks] AutoImport `*.webp` files (dotnet#7601)
  Localized file check-in by OneLocBuild Task (dotnet#7632)
  Bump $(ProductVersion) to 13.2.99
  Bump to xamarin/monodroid@c0c933b7 (dotnet#7633)
  [Xamarin.Android.Build.Tasks] Fix aapt_rules.txt corruption (dotnet#7587)
  [Xamarin.Android.Build.Tasks] Add XA1031 error (dotnet#7448)
  Bump to xamarin/Java.Interop/main@149d70f (dotnet#7625)
  [CODEOWNERS] More updates to CODEOWNERS (dotnet#7628)
  [Xamarin.Android.Build.Tasks] avoid `File.Exists()` check (dotnet#7621)
@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
3 participants