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

Including specific android libraries via nuget causes AOT failures on RELEASE build #16074

Closed
Ball opened this issue Jul 10, 2023 · 12 comments · Fixed by #16176
Closed

Including specific android libraries via nuget causes AOT failures on RELEASE build #16074

Ball opened this issue Jul 10, 2023 · 12 comments · Fixed by #16176
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working

Comments

@Ball
Copy link

Ball commented Jul 10, 2023

Description

Including Android Material 1.8.0 to match vendor native android library causes release builds to fail to AOT Microsoft.MAUI.Controls.dll.

Steps to Reproduce

Import Xamarin.Google.Android.Material 1.8.0

Build MAUI project to Release.

Link to public reproduction project repository

https://github.com/Ball/MAUIBugReprot-AndroidIncludesAOTBug

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

net7.0-android

Did you find any workaround?

No response

Relevant log output

[Microsoft.Maui.Controls.dll] Exec (with response file contents expanded) in /Users/ball/Projects/temp-crap/AndroidIncludesAOTBug/AndroidIncludesAOTBug: MONO_PATH=/Users/ball/Projects/temp-crap/AndroidIncludesAOTBug/AndroidIncludesAOTBug/obj/Release/net7.0-android/android-x64/linked: MONO_ENV_OPTIONS= /usr/local/share/dotnet/packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-x64/7.0.8/Sdk/../tools/mono-aot-cross --debug --nollvm "--aot=asmwriter,temp-path=obj/Release/net7.0-android/android-x64/aot/x86_64/Microsoft.Maui.Controls,profile-only,profile=/usr/local/share/dotnet/packs/Microsoft.Maui.Sdk/7.0.86/Sdk/maui.aotprofile,profile=/usr/local/share/dotnet/packs/Microsoft.Maui.Sdk/7.0.86/Sdk/maui-blazor.aotprofile,mtriple=x86_64-linux-android,tool-prefix=/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Darwin/binutils/bin/x86_64-linux-android-,outfile=obj/Release/net7.0-android/android-x64/aot/Microsoft.Maui.Controls.dll.so,ld-name=ld,ld-flags=--no-relax -s" "obj/Release/net7.0-android/android-x64/linked/Microsoft.Maui.Controls.dll"
            
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Precompiling failed for /Users/ball/Projects/temp-crap/AndroidIncludesAOTBug/AndroidIncludesAOTBug/obj/Release/net7.0-android/android-x64/linked/Microsoft.Maui.Controls.dll with exit code 1.
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Failed to load method 0x6002df6 from '/Users/ball/Projects/temp-crap/AndroidIncludesAOTBug/AndroidIncludesAOTBug/obj/Release/net7.0-android/android-x64/linked/Microsoft.Maui.Controls.dll' due to Could not resolve type with token 01000245 from typeref (expected class 'AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper' in assembly 'Xamarin.AndroidX.AppCompat.AppCompatResources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') assembly:Xamarin.AndroidX.AppCompat.AppCompatResources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper member:(null).
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Run with MONO_LOG_LEVEL=debug for more information.
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOT of image obj/Release/net7.0-android/android-x64/linked/Microsoft.Maui.Controls.dll failed.
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Mono Ahead of Time compiler - compiling assembly /Users/ball/Projects/temp-crap/AndroidIncludesAOTBug/AndroidIncludesAOTBug/obj/Release/net7.0-android/android-x64/linked/Microsoft.Maui.Controls.dll
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOTID CC96FD86-66AF-C4AE-30D7-A2112B3DA00A
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/usr/local/share/dotnet/packs/Microsoft.Maui.Sdk/7.0.86/Sdk/maui.aotprofile'
            /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/usr/local/share/dotnet/packs/Microsoft.Maui.Sdk/7.0.86/Sdk/maui-blazor.aotprofile'
@Ball Ball added the t/bug Something isn't working label Jul 10, 2023
@mattleibow
Copy link
Member

Can you attach a binlog?

See this for how: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis

@mattleibow mattleibow added the s/needs-info Issue needs more info from the author label Jul 11, 2023
@mattleibow
Copy link
Member

@jonathanpeppers thoughts?

@ghost
Copy link

ghost commented Jul 11, 2023

Hi @Ball. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@Ball
Copy link
Author

Ball commented Jul 11, 2023

output.binlog.zip

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Jul 11, 2023
@jonathanpeppers
Copy link
Member

@jpobst @moljac could the latest Xamarin.Google.Android.Material package be missing a dependency to Xamarin.AndroidX.AppCompat.AppCompatResources?

And then somehow everything works in Debug mode, but the AOT compiler fails in Release?

@jonathanpeppers
Copy link
Member

@Ball the latest is:

https://www.nuget.org/packages/Xamarin.Google.Android.Material/1.9.0.1

Does the latest version solve the issue?

@jpobst
Copy link
Contributor

jpobst commented Jul 11, 2023

Google renamed the DrawableWrapper type to DrawableWrapperCompat in one of their updates:
xamarin/AndroidX#690 (comment)

If MAUI uses that type directly, it may be the same issue that XF had:
xamarin/Xamarin.Forms#15668

That is, MAUI would be expecting DrawableWrapper while the user-upgraded NuGet package is providing DrawableWrapperCompat.

If this is the case, MAUI will need to update its AndroidX before users will be able to.

@jonathanpeppers
Copy link
Member

.NET 8 MAUI has the new one:

.NET 7 actually looks like it has Xamarin.Google.Android.Material 1.7.0:

@Ball so another option is to try .NET 8?

@moljac
Copy link
Contributor

moljac commented Jul 12, 2023

@jpobst @moljac could the latest Xamarin.Google.Android.Material package be missing a dependency to Xamarin.AndroidX.AppCompat.AppCompatResources?

I don't think so:

https://www.nuget.org/packages/Xamarin.Google.Android.Material/1.9.0.1#dependencies-body-tab
https://www.nuget.org/packages/Xamarin.AndroidX.AppCompat/1.6.1.2#dependencies-body-tab
https://www.nuget.org/packages/Xamarin.AndroidX.AppCompat.AppCompatResources/1.6.1.2

And then somehow everything works in Debug mode, but the AOT compiler fails in Release?

I see Pobst did answer in detail typename change.

@moljac
Copy link
Contributor

moljac commented Jul 12, 2023

.NET 8 MAUI has the new one:

Yes I added the newest few weeks ago. Seems like I need to add it to net7.0 (main) ASAP

@moljac
Copy link
Contributor

moljac commented Jul 14, 2023

@samhouts samhouts added the area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) label Jul 27, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! label Aug 8, 2023
@samhouts samhouts added this to the .NET 8 milestone Aug 8, 2023
@pulmuone
Copy link

@ghost ghost locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) fixed-in-8.0.0-preview.7.8842 Look for this fix in 8.0.0-preview.7.8842! platform/android 🤖 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants