Xamarin Forms android应用程序需要12秒才能启动 [英] Xamarin Forms android app taking 12 seconds to startup

查看:85
本文介绍了Xamarin Forms android应用程序需要12秒才能启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Xamarin构成了需要12秒启动的android应用程序,如何减少它并在2-3秒内启动?

My Xamarin forms android application taking 12 seconds to startup,How to reduce it and start within 2-3 seconds?

在我的App.Xaml.Cs文件内部,我正在创建sqlite连接.此连接需要4秒钟来创建连接.

Inside My App.Xaml.Cs File I am creating sqlite connection.This connection takes 4 second to create connection.

SQLiteConnection con = DependencyService.Get<ISQLite>().GetConnectionWithCreateDatabase();

主详细信息页面加载需要1.5秒

Master Details page loading takes 1.5 seconds

MainPage = new NavigationPage(new MasterDetailPOS() { });

在加载所有这些内容之后,还要花5秒钟,然后启动屏幕熄灭.

after loading all of this things,also taking 5 seconds then splash screen goes out.

那么如何加快这些速度?

so how to speed up these things?

推荐答案

痛苦的事实是,您永远无法将其优化到使用Xamarin.Forms在2-3秒内启动的水平,至少在当前实施. 您可以找到一些加快速度的提示:

The painful truth is that you will never be able to optimize it to the level that it starts in 2-3 seconds with Xamarin.Forms, at least within the current implementation. You can find some of the tips how to speed it up:

  • 如果您不需要立即使用数据库,建议您在完成所有必要的操作后延迟加载它
  • 启用XAML编译
  • 优化您正在使用的资产(对于不同的屏幕,检查Android )并启用<AndroidExplicitCrunch>true</AndroidExplicitCrunch>
  • 提前启用时间编译(AOT)
  • If you don't need database immediately, I would suggest to Lazy Load it after finishing all the necessary stuff
  • Enable XAML Compilation
  • Optimize the assets you are using (for different screens, check for Android) and enable <AndroidExplicitCrunch>true</AndroidExplicitCrunch>
  • Enable Ahead of Time Compilation (AOT)

这篇关于Xamarin Forms android应用程序需要12秒才能启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆