[Xamarin.Forms][Android] XA3001: Could not AOT the assembly: Microsoft.Graph.dll
Describe the bug After upgrading to Microsoft.Graph 5.x (from 4.x) I'm seeing the following error creating a release Android archive build:
XA3001: Could not AOT the assembly: Microsoft.Graph.dll
To Reproduce I do not know if this reproduces 100% on all Xamarin.Forms Android projects or not.
Expected behavior I'd expect to be able to successfully AOT this assembly.
Please let me know if you need additional information for this one. I will likely have to revert to 4.x.
Thanks.
I should note this fails with both 5.12.0 and 5.13.0. Haven't tried other versions.
@andrueastman: are you aware of any workarounds for this? Thanks.
This is fixed in main of dotnet/runtime but there's no backport to net7.0 yet. https://github.com/dotnet/runtime/issues/87061
You can workaround it with this in your project:
<TrimmableAssembly Include="Microsoft.Graph" />
Thanks, @NickDarvey.
My project layout is as follows: Android csproj -> Xamarin.Forms csproj -> .NET Standard 2.0 assembly csproj -> Microsoft.Graph.
I've added this to each of the three csproj files as follows:
<ItemGroup>
<TrimmableAssembly Include="Microsoft.Graph" />
</ItemGroup>
However, I still see the error archiving the Android project:
XA3001: Could not AOT the assembly: Microsoft.Graph.dll
Oh, perhaps it's a different issue then. Sorry @mfeingol! I'd suggest capturing a binlog and opening an issue in either xamarin/xamarin-android or dotnet/runtime similar to this one. They're much more responsive.
See also workaround described in https://github.com/xamarin/xamarin-android/issues/5764
@NickDarvey: thanks for the note. That second workaround doesn't help either. So ... do you know how I can capture a binlog for the Android "archive" function in VS? That's where the error happens.
So ... do you know how I can capture a binlog for the Android "archive" function in VS? That's where the error happens.
It looks like you can get the binlog by setting an envvar or this extension.
@NickDarvey: unfortunately the extension lists no content when archiving, and the env var results in lots of logs that do not contain the word "Graph" so they do not appear to have useful data either.
Any other suggestions?
The env var would produce a .binlog, probably in your project directory. The extension will let you save a binlog, as shown here.
In either case, if you open the binlog with a viewer it should mention 'graph' because your error mentions 'graph' (and the error will definitely be in there).
@NickDarvey: please feel free to take a look at the output I did get. And there's no .binlog in my project directory.
I'm guessing the Xamarin Android archive function doesn't use MSBuild...
You should open an issue and share your binlog in xamarin/xamarin-android
@NickDarvey: on closer look, this issue is a dup of https://github.com/dotnet/runtime/issues/85917. I'm seeing the following text in diagnostic build logs:
[aot-compiler stdout] * Assertion at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mono/mini/aot-compiler.c:10858, condition `table_size < 65000' not met
@andrueastman: please cf this comment: https://github.com/dotnet/runtime/issues/85917#issuecomment-1538827966 - is there a way for Microsoft.Graph.dll to not include this many methods? I'm wondering why that's needed given my very minimal use of Graph in my app (essentially accessing a few OneDrive functions).
I also filed https://github.com/xamarin/xamarin-android/issues/8274 for this.
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <RunAOTCompilation>false</RunAOTCompilation> <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot> </PropertyGroup>
This should be resolved via https://github.com/microsoftgraph/msgraph-sdk-dotnet/pull/2182 and release https://www.nuget.org/packages/Microsoft.Graph/5.32.0
@andrueastman: this still isn't working.
<PackageReference Include="Microsoft.Graph" Version="5.32.0" />
[aot-compiler stdout] Running: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Xamarin\\Android\\binutils\\bin\\llvm-mc.exe" --arch=arm --triple=arm-linux-gnu --assemble --filetype=obj --mattr=+armv7-a,+vfp3 -o=obj\Release\130\aot\armeabi-v7a\SQLitePCLRaw.provider.e_sqlite3.dll\temp-llvm.o obj\Release\130\aot\armeabi-v7a\SQLitePCLRaw.provider.e_sqlite3.dll\temp-llvm.s
XA3001: Could not AOT the assembly: Microsoft.Graph.dll
@andrueastman: let me know if you need access to an app that reproduces the problem. Thanks.