dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.96k stars 4.65k forks source link

Android app doesn't build in Release mode (Mono Ahead of Time compiler) #107202

Open munkii opened 3 weeks ago

munkii commented 3 weeks ago

Description

When building in Release mode the app would not build.

Precompiling failed for C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-arm64\linked\ProjectBreatheApp.Maui.dll with exit code -1073740791. Unable to compile method 'void ProjectBreatheApp.Maui.Views.Settings.PushNotifications:InitializeComponent ()' due to: 'Method with open type while not compiling gshared'. Mono Ahead of Time compiler - compiling assembly C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-arm64\linked\ProjectBreatheApp.Maui.dll AOTID FE3741B1-52EE-CE48-B1DF-9E41B11C9BC4

  • Assertion at D:\a_work\1\s\src\mono\mono\mini\method-to-ir.c:6460, condition `!sig->has_type_parameters' not met ProjectBreatheApp.Maui (net8.0-android34.0) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets 109

The issue is our XAML. Note the syntax in the XAML that is using an array index!


Grid x:DataType="settingsViewModels:PushNotificationsItemViewModel" BindingContext="{Binding Categories[1]}">
        <Grid.ColumnDefinitions>
                <ColumnDefinition Width="6*" />
                <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
        <Label
            Grid.Column="0"
            VerticalOptions="Center"
            Margin="12,0,0,0"
            Text="{Binding Name}" />

        <Switch
            Grid.Column="1"
                IsToggled="{Binding Enabled}"
                VerticalOptions="Center" />         
</Grid>

Steps to Reproduce

App works fine in Debug mode but switching to Release and trying to Build will fail. I have a workaround and to be fair the workaround" is better than the nastiness I was doing previously. I only raise this issue as it is a bug even if what I am doing is wrong

Link to public reproduction project repository

No response

Version with bug

8.0.80 SR8

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

Switch from using an array index in the BindingContext

BindingContext="{Binding Categories[1]}"

To

BindingContext="{Binding NewsCategory}"

Relevant log output

> 12>[ProjectBreatheApp.Maui.dll] Exec (with response file contents expanded) in C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui: MONO_PATH=C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-x86\linked; MONO_ENV_OPTIONS= C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-x86\8.0.8\Sdk\..\tools\mono-aot-cross.exe --debug --nollvm "--aot=asmwriter,temp-path=obj\Release\net8.0-android34.0\android-x86\aot\x86\ProjectBreatheApp.Maui,mtriple=i686-linux-android,tool-prefix=C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\tools\binutils\bin\i686-linux-android-,outfile=obj\Release\net8.0-android34.0\android-x86\aot\ProjectBreatheApp.Maui.dll.so,temp-path=obj\Release\net8.0-android34.0\android-x86\ProjectBreatheApp.Maui.dll.tmp,ld-name=ld,ld-flags=--no-relax -s" "obj\Release\net8.0-android34.0\android-x86\linked\ProjectBreatheApp.Maui.dll"
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Precompiling failed for C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-x86\linked\ProjectBreatheApp.Maui.dll with exit code -1073740791.
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Unable to compile method 'void ProjectBreatheApp.Maui.Views.Settings.PushNotifications:InitializeComponent ()' due to: 'Method with open type while not compiling gshared'.
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Mono Ahead of Time compiler - compiling assembly C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-x86\linked\ProjectBreatheApp.Maui.dll
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : AOTID B673A320-D2EE-E14E-37E5-7A5196D1E4D1
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : * Assertion at D:\a\_work\1\s\src\mono\mono\mini\method-to-ir.c:6460, condition `!sig->has_type_parameters' not met
> 12>[ProjectBreatheApp.Maui.dll] Exec (with response file contents expanded) in C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui: MONO_PATH=C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-arm64\linked; MONO_ENV_OPTIONS= C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64\8.0.8\Sdk\..\tools\mono-aot-cross.exe --debug --nollvm "--aot=asmwriter,temp-path=obj\Release\net8.0-android34.0\android-arm64\aot\arm64-v8a\ProjectBreatheApp.Maui,mtriple=aarch64-linux-android,tool-prefix=C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\tools\binutils\bin\aarch64-linux-android-,outfile=obj\Release\net8.0-android34.0\android-arm64\aot\ProjectBreatheApp.Maui.dll.so,temp-path=obj\Release\net8.0-android34.0\android-arm64\ProjectBreatheApp.Maui.dll.tmp,ld-name=ld,ld-flags=--no-relax -s" "obj\Release\net8.0-android34.0\android-arm64\linked\ProjectBreatheApp.Maui.dll"
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Precompiling failed for C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-arm64\linked\ProjectBreatheApp.Maui.dll with exit code -1073740791.
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Unable to compile method 'void ProjectBreatheApp.Maui.Views.Settings.PushNotifications:InitializeComponent ()' due to: 'Method with open type while not compiling gshared'.
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : Mono Ahead of Time compiler - compiling assembly C:\Projects\MB\breathe.breatherm-app\ProjectBreatheApp.Maui\obj\Release\net8.0-android34.0\android-arm64\linked\ProjectBreatheApp.Maui.dll
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : AOTID FE3741B1-52EE-CE48-B1DF-9E41B11C9BC4
> 12>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.113\targets\Microsoft.Android.Sdk.Aot.targets(109,5): error : * Assertion at D:\a\_work\1\s\src\mono\mono\mini\method-to-ir.c:6460, condition `!sig->has_type_parameters' not met
>
github-actions[bot] commented 3 weeks ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

jpobst commented 2 weeks ago

@grendello @jonathanpeppers This may be dotnet/runtime but I'll let you decide.

grendello commented 2 weeks ago

Yep, it's MonoVM. @jonathanpeppers could you transfer it to the runtime? Thanks :)