I'm trying to release mobile application in Xamarin.Forms on Android. However, Android startup time is insane and unacceptable (about 10 seconds on some devices).
I've spent several hours browsing internet to find some optimizations. Therefore I've got installed latest version of Visual Studio for Mac, NDK and Mono. I also optimized assets and turned on XAML compilation. Plus I removed almost all initialization from MainActivity and MainApplication OnCreate event (also from my main view).
After all it turned out, that the only thing that cause any improvement is turning on AOT. Therefore I tested it with the following options:
<AotAssemblies>True</AotAssemblies> <AndroidAotMode>Normal</AndroidAotMode> <EnableLLVM>true</EnableLLVM>
Startup time dropped to about 4.5s, which is better. I thought that I will publish this update. But somehow it turned out that after "Archive for publishing" this APK is even slower than without AOT. Now even scrolling in the application works terribly slow.
Any ideas how to fix the problem? I don't know why release uploaded from Visual Studio is so dramatically different than the one generated for publishing (even using the same scheme - Release).
Full Release configuration: