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

MAUI failed to compile with AOT #81913

Closed
succeed318 opened this issue Jan 29, 2023 · 12 comments
Closed

MAUI failed to compile with AOT #81913

succeed318 opened this issue Jan 29, 2023 · 12 comments
Assignees

Comments

@succeed318
Copy link

succeed318 commented Jan 29, 2023

11

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>net6.0-android</TargetFrameworks>
		<OutputType>Exe</OutputType>
		<RootNamespace>IotTencent</RootNamespace>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>
		<ImplicitUsings>enable</ImplicitUsings>

		<!-- Display name -->
		<ApplicationTitle>XXXXXX</ApplicationTitle>

		<!-- App Identifier -->
		<ApplicationId>com.companyname.iottencent</ApplicationId>
		<ApplicationIdGuid>2695fcd7-bfcb-4b7b-8eb2-f754a9e0b289</ApplicationIdGuid>

		<!-- Versions -->
		<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
		<ApplicationVersion>1</ApplicationVersion>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
	</PropertyGroup>

	<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
		<ApplicationTitle>XXX</ApplicationTitle>
		<AndroidPackageFormat>apk</AndroidPackageFormat>
               <EnableLLVM>False</EnableLLVM>

		<RunAOTCompilation>True</RunAOTCompilation>
		<PublishTrimmed>True</PublishTrimmed>

	</PropertyGroup>

	<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
	  <EnableLLVM>False</EnableLLVM>
	</PropertyGroup>
	<ItemGroup>
		<!-- App Icon -->
		<MauiSplashScreen Include="Resources\Splash\splash.png" />

		<!-- Splash Screen -->

		<!-- Images -->
		<MauiImage Include="Resources\Images\*" />
		<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

		<!-- Custom Fonts -->
		<MauiFont Include="Resources\Fonts\*" />

		<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
		<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
	</ItemGroup>

	<ItemGroup>
		<None Remove="Resources\AppIcon\appicon.png" />
		<None Remove="Resources\Fonts\iconfont.ttf" />
		<None Remove="Resources\Splash\splash.png" />
	</ItemGroup>

	<ItemGroup>
		<MauiIcon Include="Resources\AppIcon\appicon.png" BaseSize="128,128" />
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
		<PackageReference Include="TencentCloudSDK" Version="3.0.679" />
	</ItemGroup>

	<ItemGroup>
		<None Update="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
		<None Update="Resources\Splash\splash11.svg" Color="#512BD4" BaseSize="128,128" />
	</ItemGroup>

	<ItemGroup>
		<MauiXaml Update="Views\Home.xaml">
			<Generator>MSBuild:Compile</Generator>
		</MauiXaml>
		<MauiXaml Update="Views\Start.xaml">
			<Generator>MSBuild:Compile</Generator>
		</MauiXaml>
	</ItemGroup>

</Project>

use follow config:

<RunAOTCompilation>True</RunAOTCompilation>
<PublishTrimmed>True</PublishTrimmed>

<ItemGroup>
		<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
		<PackageReference Include="TencentCloudSDK" Version="3.0.679" />
</ItemGroup>
  1. Create a MAUI APP project with VS2022(Version 17.4.4)
  2. install TencentCloud.dll from nuget;
  3. direct publish project,
    it takes very long,long time; about three hours. finally compiler fail.
@jsuarezruiz
Copy link

@jonathanpeppers Thoughts?

@jonathanpeppers
Copy link
Member

@jsuarezruiz the error message in the screenshot has the same Assertion table_size error as this one:

#81271

@succeed318
Copy link
Author

How do I generate apk using the default configuration;
Use the following configuration to generate the APK:

<RunAOTCompilation>True</RunAOTCompilation>
<PublishTrimmed>True</PublishTrimmed>

What should i change?

@succeed318
Copy link
Author

@jonathanpeppers

Change to the following configuration, can be generated normally. The resulting apk is about 60MB.

<RunAOTCompilation>False</RunAOTCompilation>
<PublishTrimmed>False</PublishTrimmed>

image

@jonathanpeppers
Copy link
Member

RunAOTCompilation=false would be all you need to turn off AOT.

PublishTrimmed=false turns off the trimmer/linker, that probably isn't solving anything and would make the app large (as you noticed).

@danielancines
Copy link

danielancines commented Feb 8, 2023

Hi guys,

I'm getting the same error, any thoughts? But in my case, I'm getting error with a brand new Maui project.

@jonathanpeppers
Copy link
Member

@danielancines I would file a new issue, everyone here is getting:

* Assertion at D:\a\_work\1\s\src\mono\mono\mini\aot-compiler.c:11219, condition `table_size < 65000' not met 

And it's not happening with new projects.

@danielancines
Copy link

@jonathanpeppers Using the command dotnet publish -r win-x64 -c Release -f net7.0-windows10.0.19041.0 I'm getting this error on a brand new Maui project:
dotnet\sdk\7.0.102\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(278,5): error MSB3073: The command ""C:\Users\ancineda\.nuget\packages\[runtime.win](http://runtime.win/)-x64.microsoft.dotnet.ilcompiler\7.0.2\tools\\ilc" @"obj\Release\net7.0-windows10.0.19041.0\win-x64\native\Maui.AOT.ilc.rsp"" exited with code 1. [C:\code\Maui.AOT\Ma ui.AOT\Maui.AOT.csproj::TargetFramework=net7.0-windows10.0.19041.0]

S.O: Windows 10
Visual Studio 2022 - 17.4.4

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 9, 2023
@jsuarezruiz jsuarezruiz transferred this issue from dotnet/maui Feb 9, 2023
@lewing
Copy link
Member

lewing commented May 8, 2023

looks like #81271

@drossoft
Copy link

Im my case, it happens when I add Microsoft.Graph (5.11.0)

Visual Studio Community 17.6.1

Error Precompiling failed for C:\git\MyProject\MyProject\obj\Release\net7.0-android\android-arm64\linked\Microsoft.Graph.dll with exit code -1073740791.
Mono Ahead of Time compiler - compiling assembly C:\git\MyProject\MyProject\obj\Release\net7.0-android\android-arm64\linked\Microsoft.Graph.dll
AOTID EA8EE00C-DBA5-6597-5F0E-0883CCE33C29
Using profile data file 'C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\7.0.86\Sdk\maui.aotprofile'
Using profile data file 'C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\7.0.86\Sdk\maui-blazor.aotprofile'
Added 0 methods from profile.
Added 0 methods from profile.

  • Assertion at D:\a_work\1\s\src\mono\mono\mini\aot-compiler.c:11219, condition `table_size < 65000' not met MyProject C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.46\targets\Microsoft.Android.Sdk.Aot.targets 91

The same error appears 4 times, for android-arm64, android-x86, android-x64 and android-arm

@vargaz
Copy link
Contributor

vargaz commented May 23, 2023

#85917

@lewing
Copy link
Member

lewing commented Jun 1, 2023

should be fixed by #85952

@lewing lewing closed this as completed Jun 1, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jun 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants