Android 应用程序初始启动时间缓慢 [英] Android app slow initial startup time

查看:57
本文介绍了Android 应用程序初始启动时间缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我开始使用 android 支持设计库中的 UI 元素后,应用的初始加载时间变得非常缓慢(大约 8 秒!),我真的不知道为什么.

After I started using UI elements from the android support design library the app initial load time has become really slow (about 8 seconds!) and I am really not sure why.

我在启动的大部分时间都运行了方法跟踪(android studio 开始运行 cpu 监视器需要时间),发现它花费了 4 秒钟:dalvik.system.DexFile.openDexFile,我不知道为什么要花这么长时间.

I ran method tracking during most of the startup (It takes time for android studio to start running the cpu monitor) and found it spend 4 seconds on: dalvik.system.DexFile.openDexFile, Im not sure why this is taking so long.

有什么想法吗?(我没有添加任何代码,因为我的应用程序中有很多代码,我不知道问题出在哪里......)

Any ideas? (I didnt add any code since there is a lot of code in my app and I dont know where the problem is coming from...)

推荐答案

在构建发布应用程序而不是我通常运行的调试版本时,我发现速度有所提高.

I experienced an increase in speed when building the release app instead of the debug version that I normaly run.

我不确定它为什么起作用,但我想这一定是因为编译器将 ext 库链接到 apk 的方式.我曾经看过 Chet Haase 的采访,他是 android ui 平台上的开发人员之一,他解释了他们如何尝试尽快在应用程序上显示第一个活动以避免启动画面沉闷.也许在发布构建过程中以某种方式启用了该功能.

I'm not sure why it works, but I guess it has to be because of the way the compiler links the ext libs into the apk. I once saw an interview with Chet Haase who is one of the devs on the android ui platform, who explained how they were trying to show the first activity on the app as quickly as possible to avoid dull splash screen. Maybe that feature is somehow enabled in the release build process.

正确答案由@Embydextrous 写在下面.是应用在debug模式下dexing造成的.

The correct answer is written below by @Embydextrous. It is cause by the dexing of the app in debug mode.

这篇关于Android 应用程序初始启动时间缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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