- Information usually found in AndroidManifest is split into three files.
AndroidManifest.xmlfor various options, intent filters providers etc.AssemblyInfo.csfor the permissions.Main.csfor the<Application>properties.
Labelis set in Main.cs to a resource. For Android this ApplicationName resource is located inResources/values/Strings.xml. Resources.resw in the Shared project is not used for the label on Android.
In order to get better startup performance on Android, this application is bootstrapped using profiled AOT.
This is a special type of compilation that uses a generated file (custom.aprof) to optimize the AOT compilation.
To generate this file, following the following steps:
- Open a command prompt or terminal against your Android project’s directory that contains the .csproj.
- Ensure only one Android device is attached.
- Execute the following command:
dotnet build -f net9.0-android35.0 -t:BuildAndStartAotProfiling- The dotnet version targeted must match the one specified in the mobile csproj.
- If you have a custom Android SDK path, you can specify it with the
AndroidSdkPathproperty.💡
-p:AndroidSdkDirectory=path/to/android/sdk
- Let your application run until it’s loaded.
- Execute the following command:
dotnet build -f net9.0-android35.0 -t:FinishAotProfiling.- The dotnet version targeted must match the one specified in the mobile csproj.
- If you have a custom Android SDK path, you can specify it with the
AndroidSdkPathproperty.💡
-p:AndroidSdkDirectory=path/to/android/sdk
- Use this configuration in your
.csproj.
<EnableLLVM>True</EnableLLVM>
<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>
<AndroidUseDefaultAotProfile>False</AndroidUseDefaultAotProfile>
<PackageReference Include="Mono.AotProfiler.Android" Version="7.0.0" />
<AndroidAotProfile Include="$(MSBuildThisFileDirectory)custom.aprof" />If the iOS application is crashing instantly on launch, it may be caused by the AOT compilation (ahead of time) for iOS. Some NuGet packages don’t always support the necessary AOT conditions and instead are JIT compiled (just in time).
- Connect your iPhone to your Mac via cable.
- Open the 'Console' application on your Mac.
- Choose your phone and click on start stream.
- Open the application that has the problem.
- Search for the error in the Mac 'Console' application, it should provide you with the assembly that is causing the issue.
💡 Search for 'Failed to load AOT module'.
- Then include it in the list of assemblies that should be interpreted.
<ItemGroup> <MtouchInterpreter>-all,InterpretedAssembly</MtouchInterpreter> </ItemGroup>
- Try again, sometime you may need to add more assemblies to the list.