Skip to content

Xamarin.Android project build fails after upgrading to Visual Studio 17.3.5 (from 17.2.5) due to missing .dll in AOT folder and aapt_rules.txt #7447

Description

@vilinet

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

VS 17.3.5

Description

Not a single change in our project or CI script, just VS got update to the currently latest one and we experience 2 strange and blocker side-effect during AOT apk build, that can be strangely workaround if we get rid of those packages, but still nothing change on our side at all aside the VS update:

First:
It looks like some .dll is not getting copied/generated into the target folder anymore like Humanizer or PublicHoliday give us this error at the very end of the AOT process when it tries to zip the aot files into a zip:
"X.Android.csproj" (SignAndroidPackage target) (1) -> (_BuildApkEmbed target) -> C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2049,3): error XABLD7028: Sy [MissingDllDuringAOT.zip](https://github.com/xamarin/xamarin-android/files/9745881/MissingDllDuringAOT.zip) stem.IO.FileNotFoundException: Could not find file 'X.Android\obj\DEV-Release\110\aot\arm64-v8a\libaot-PublicHoliday.dll.so'. [X.Android.csproj] C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2049,3): error XABLD7028: File name: 'X.Android\obj\DEV-Release\110\aot\arm64-v8a\libaot-PublicHoliday.dll.so'

Second error that even if we get those things fixed, we get now these errors during the "startup" phase of the build that we have no idea so far why and can't even workaround it:

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

I hope someone can help why these now happen and some possible workaround to fix these issues

Steps to Reproduce

I can reproduce the error by trying to build the attached MissingDllDuringAOT.zip in Release mode.

Did you find any workaround?

No response

Relevant log output

Severity Code Description Project File Line Suppression State Error XABBA7028: System.IO.FileNotFoundException: Could not find file 'C:\Users\Charlie\Downloads\MissingDllDuringAOT\MissingDllDuringAOT\MissingDllDuringAOT\obj\Release\110\aot\armeabi-v7a\libaot-Humanizer.dll.so'. File name: 'C:\Users\Charlie\Downloads\MissingDllDuringAOT\MissingDllDuringAOT\MissingDllDuringAOT\obj\Release\110\aot\armeabi-v7a\libaot-Humanizer.dll.so' at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.GetAttributes(String path) at Xamarin.Tools.Zip.WindowsPlatformServices.IsDirectory(ZipArchive archive, String path, Boolean& result) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/WindowsPlatformServices.cs:line 47 at Xamarin.Tools.Zip.PlatformServices.CallServices(Func2 code) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/PlatformServices.cs:line 166
at Xamarin.Tools.Zip.PlatformServices.IsDirectory(ZipArchive archive, String path) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/PlatformServices.cs:line 74
at Xamarin.Tools.Zip.ZipArchive.AddFile(String sourcePath, String archivePath, EntryPermissions permissions, CompressionMethod compressionMethod, Boolean overwriteExisting) in /Users/runner/work/1/s/LibZipSharp/Xamarin.Tools.Zip/ZipArchive.cs:line 406
at Xamarin.Android.Tasks.BuildApk.ExecuteWithAbi(String[] supportedAbis, String apkInputPath, String apkOutputPath, Boolean debug, Boolean compress, IDictionary2 compressedAssembliesInfo, String assemblyStoreApkName) at Xamarin.Android.Tasks.BuildApk.RunTask() at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 0 _No response_

Activity

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    needs-triageIssues that need to be assigned.
    on Oct 10, 2022
  2. changed the title [-]Xamarin.Android project build fails after upgrading to latest Visual Studio 17.3.5 due to missing .dll in AOT folder and also [/-] [+]Xamarin.Android project build fails after upgrading to latest Visual Studio 17.3.5 due to missing .dll in AOT folder and aapt_rules.txt[/+] on Oct 10, 2022
  3. changed the title [-]Xamarin.Android project build fails after upgrading to latest Visual Studio 17.3.5 due to missing .dll in AOT folder and aapt_rules.txt[/-] [+]Xamarin.Android project build fails after upgrading to Visual Studio 17.3.5 (from 17.2.5) due to missing .dll in AOT folder and aapt_rules.txt[/+] on Oct 10, 2022
  4. dellis1972 commented on Oct 10, 2022

    @dellis1972
    Contributor

    Hi, The second error seems to be related to the AndroidLinkTool which you are using in your project.
    I think the recommendation is to use r8 now for the AndroidLinkTool for release builds and d8 for debug. You might need to delete your bin/obj folders to get a clean build on upgrade. The error suggests that the format of the aapt_rules.txt file has changed and the old version is now incompatible. This file is auto generated by aapt2 during the build pocess.

    Can you provide a diagnostic build log which contains the error ?

    This can be done on the Visual Studio Developer Command Prompt. You can navigate to your project directory then use

    msbuild Demo.Android.csproj /restore /p:Configuration=Release /t:SignAndroidPackage /bl
    

    This will produce a msbuild.binlog file which you can zip up and attach to this issue.

  5. added
    need-infoIssues that need more information from the author.
    and removed
    needs-triageIssues that need to be assigned.
    on Oct 10, 2022
  6. vilinet commented on Oct 10, 2022

    @vilinet
    Author

    @dellis1972
    I will run it soon with the logging.

    Until that, This issue happens in release only anyway and we always build with cleaned/removed bin/obj dirs.

    This is the Android.csproj related section:
    <AndroidManagedSymbols>true</AndroidManagedSymbols> <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <AndroidLinkMode>SdkOnly</AndroidLinkMode> <AotAssemblies>true</AotAssemblies> <AndroidLinkTool>r8</AndroidLinkTool> <AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi> <AndroidKeyStore>true</AndroidKeyStore> <AndroidApkSignerAdditionalArguments>--v2-signing-enabled true</AndroidApkSignerAdditionalArguments>

  7. vilinet commented on Oct 10, 2022

    @vilinet
    Author

    Regarding the missing AOT-d dlls, i noticed that the 2 libs we have issues with, Humanizer and PublicHoliday, both uses local-dependent nuget packages as dependencies.
    So i wonder if something changed/broke in msbuild local resolution causing AOT not finding the proper local-dependent dll for AOt-ing?

  8. ghost removed
    need-infoIssues that need more information from the author.
    on Oct 10, 2022
  9. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Oct 10, 2022
  10. vilinet commented on Oct 10, 2022

    @vilinet
    Author

    I cant really provide the logs as they are kind of private for now, i will try to replicate it with a new project, BUT
    I found something strange, i found out why the aapt_rules are failing,
    it looks like the aapt_rules.txt file is not getting flushed properly during the generation.
    Sometimes the CI has no issue and it just builds that, but most of the time the aapt_rules.txt has some random "garbage" due to some bad stream flushing:

    Like here:
    image
    Seemingly in the 128th line, the -keep and "#Referenced at" line got merged somehow into a single line.

    So i am gonna have a look at our CI.
    But the missing .dll is still happening on every machine.

  11. 17 remaining items

  12. melimion commented on Nov 29, 2022

    @melimion

    @jonathanpeppers , try remove bin and obj folders and then Rebuild project. Not Build or Deploy.
    Rebuild reproduces aapt_rules.txt issue.

    If I use Build, projects builds successfully.
    If I use Deploy, your issue with Humanizer reproduced.

  13. ghost removed
    need-infoIssues that need more information from the author.
    on Nov 29, 2022
  14. ghost added
    need-attentionA xamarin-android contributor needs to review
    on Nov 29, 2022
  15. dellis1972 commented on Nov 29, 2022

    @dellis1972
    Contributor

    @melimion I think this is related to the AndroidCreatePackagePerAbi setting.
    can you try turning that off?

    I think whats happening is multiple calls to aapt2 link are using the same file, and they are tripping over each other.

  16. melimion commented on Nov 29, 2022

    @melimion

    @dellis1972 looks like you're right, 5 rebuilds with <AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi> succeded

  17. dellis1972 commented on Nov 29, 2022

    @dellis1972
    Contributor

    @melimion ok cool good to know, I'm working on a fix 👍

  18. added 5 commits that reference this issue on Nov 29, 2022
    98e1dfb
    9cef633
    4623e8a
    d1171d5
    78c08d2
  19. ghost locked as resolved and limited conversation to collaborators on Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions