Xamarin.Forms Android AOT support

那年仲夏 提交于 2019-12-24 09:10:02

问题


does anyone know how to use AOT compilation instead of JIT for Xamarin.Forms Android project? Im simply unhappy with the boot times of Android app while iOS starts like it should (since iOS is forced to use AOT).

Also in which file specifically should I enable XAMLC? Right now im doing it inside Android project and iOS project AssemblyInfo files.

Thanks!


回答1:


Within the Release configuration PropertyGroup in your Xamarin.Android's .csproj file, add a AotAssemblies element that is set to true, optionally add an EnableLLVM element.

Note: As this will increase the size of your APK, my advice would be to make sure that the Mono Linker is active in your release config ("Link all assemblies" would be ideal to remove as much unused IL are possibly before the AOT process takes place to help minimize the size of each native shared library)

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ~~~
    <AotAssemblies>true</AotAssemblies>
    <EnableLLVM>true</EnableLLVM>
    ~~~
</PropertyGroup>

AotAssemblies – A boolean property that determines whether or not assemblies will be Ahead-of-Time compiled into native code and included in the .apk.

EnableLLVM – A boolean property that determines whether or not LLVM will be used when Ahead-of-Time compiling assemblies into native code.

re: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-process



来源:https://stackoverflow.com/questions/51961132/xamarin-forms-android-aot-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!