msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

[Xamarin.Forms][Android] XA3001: Could not AOT the assembly: Microsoft.Graph.dll

Open mfeingol opened this issue 2 years ago • 17 comments

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.

mfeingol avatar Jun 09 '23 04:06 mfeingol

I should note this fails with both 5.12.0 and 5.13.0. Haven't tried other versions.

mfeingol avatar Jun 09 '23 19:06 mfeingol

@andrueastman: are you aware of any workarounds for this? Thanks.

mfeingol avatar Jun 10 '23 16:06 mfeingol

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" />

NickDarvey avatar Jun 12 '23 04:06 NickDarvey

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

mfeingol avatar Jun 12 '23 16:06 mfeingol

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 avatar Jun 12 '23 22:06 NickDarvey

@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.

mfeingol avatar Jun 12 '23 23:06 mfeingol

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 avatar Jun 12 '23 23:06 NickDarvey

@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?

mfeingol avatar Jun 17 '23 23:06 mfeingol

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 avatar Jun 18 '23 09:06 NickDarvey

@NickDarvey: please feel free to take a look at the output I did get. And there's no .binlog in my project directory.

Logs.zip

I'm guessing the Xamarin Android archive function doesn't use MSBuild...

mfeingol avatar Aug 15 '23 00:08 mfeingol

You should open an issue and share your binlog in xamarin/xamarin-android

NickDarvey avatar Aug 15 '23 00:08 NickDarvey

@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).

mfeingol avatar Aug 15 '23 01:08 mfeingol

I also filed https://github.com/xamarin/xamarin-android/issues/8274 for this.

mfeingol avatar Aug 15 '23 01:08 mfeingol

<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <RunAOTCompilation>false</RunAOTCompilation> <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot> </PropertyGroup>

sereoja avatar Aug 31 '23 19:08 sereoja

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 avatar Oct 26 '23 11:10 andrueastman

@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

mfeingol avatar Oct 26 '23 17:10 mfeingol

@andrueastman: let me know if you need access to an app that reproduces the problem. Thanks.

mfeingol avatar Nov 06 '23 18:11 mfeingol