android第一次启动超级慢

2024-09-02 20:48

本文主要是介绍android第一次启动超级慢,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

今天测试反馈,第一次启动,开屏超级慢,大概再7S 左右。

开始的时候,我去再WelcomeActivity 那里加了log,发现过了很久才打印。

然后我就再Application 的onAttachBase, onCreate 里面加log.

结果发现,从attachBaseContext 到执行onCreate 这期间花费了4S时间。

2019-08-30 15:59:25.026 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext
2019-08-30 15:59:25.194 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext cost168
2019-08-30 15:59:29.679 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate

那这个时间,就不是我们的操作了。看下过滤了ad2_Log_output 的日志:

2019-08-30 15:59:25.026 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext
2019-08-30 15:59:25.194 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext cost168
2019-08-30 15:59:29.679 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate
2019-08-30 15:59:29.757 27385-27385/com.chaozh.iReader D/ad2_Log_output: 加载广告计时开始:1567151969757
2019-08-30 15:59:29.757 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate cost78
2019-08-30 15:59:30.346 27385-27385/com.chaozh.iReader D/ad2_Log_output: enableThirdAd proxy.adTypeSwitchOn(): false
2019-08-30 15:59:30.348 27385-27385/com.chaozh.iReader E/ad2_Log_output: welcome oncreate enableThirdAd: true ,isInThirdTime : true ,userSupportAd : true
2019-08-30 15:59:30.348 27385-27385/com.chaozh.iReader D/ad2_Log_output: 当前加载广告类型:null
2019-08-30 15:59:30.366 27385-27385/com.chaozh.iReader D/ad2_Log_output:  welcome oncreate mWelcomeAdView: com.chaozh.iReader.ui.activity.WelcomeAdView{6541bb4 V.E...... ......ID 0,0-0,0}

我们再看下这期间,其他的日志:

2019-08-30 15:59:25.242 27410-27410/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.242 27410-27410/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.243 27410-27410/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_config/1567151755000.apk --output-vdex-fd=58 --oat-fd=59 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_config/oat/arm/1567151755000.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:25.349 27410-27410/? I/dex2oat: dex2oat took 108.005ms (96.173ms cpu) (threads: 4) arena alloc=28KB (28824B) java alloc=64KB (65552B) native alloc=504KB (517040B) free=1543KB (1580112B)
2019-08-30 15:59:25.406 27417-27417/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.406 27417-27417/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.407 27417-27417/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_mine/1567151746872.apk --output-vdex-fd=59 --oat-fd=60 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_mine/oat/arm/1567151746872.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:25.642 27417-27417/? I/dex2oat: dex2oat took 236.792ms (458.101ms cpu) (threads: 4) arena alloc=16KB (17096B) java alloc=638KB (654000B) native alloc=953KB (976408B) free=1606KB (1645032B)
2019-08-30 15:59:25.714 27424-27424/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.715 27424-27424/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.715 27424-27424/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_video/1567151747044.apk --output-vdex-fd=60 --oat-fd=61 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_video/oat/arm/1567151747044.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.007 27424-27424/? I/dex2oat: dex2oat took 292.551ms (538.776ms cpu) (threads: 4) arena alloc=27KB (28144B) java alloc=520KB (532880B) native alloc=1386KB (1420008B) free=1685KB (1725720B)
2019-08-30 15:59:26.181 27430-27430/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.181 27430-27430/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.181 27430-27430/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_business/1567151758728.apk --output-vdex-fd=62 --oat-fd=63 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_business/oat/arm/1567151758728.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.313 27430-27430/? I/dex2oat: dex2oat took 132.834ms (184.244ms cpu) (threads: 4) arena alloc=19KB (19856B) java alloc=146KB (150448B) native alloc=734KB (751992B) free=1313KB (1345160B)
2019-08-30 15:59:26.393 27437-27437/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.394 27437-27437/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.394 27437-27437/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookdetail/1567151758669.apk --output-vdex-fd=63 --oat-fd=64 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookdetail/oat/arm/1567151758669.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.744 27437-27437/? I/dex2oat: dex2oat took 351.174ms (813.728ms cpu) (threads: 4) arena alloc=7KB (8016B) java alloc=1378KB (1411200B) native alloc=1457KB (1492560B) free=1614KB (1653168B)
2019-08-30 15:59:26.846 27442-27442/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.846 27442-27442/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.846 27442-27442/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_pdf/1567151747864.apk --output-vdex-fd=64 --oat-fd=65 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_pdf/oat/arm/1567151747864.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:27.030 27442-27442/? I/dex2oat: dex2oat took 184.560ms (286.851ms cpu) (threads: 4) arena alloc=18KB (18824B) java alloc=287KB (293960B) native alloc=952KB (975784B) free=1607KB (1645656B)
2019-08-30 15:59:27.102 27447-27447/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:27.103 27447-27447/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:27.103 27447-27447/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore/1567151780572.apk --output-vdex-fd=65 --oat-fd=66 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore/oat/arm/1567151780572.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:27.900 27447-27447/? I/dex2oat: dex2oat took 797.989ms (2.040s cpu) (threads: 4) arena alloc=11KB (11760B) java alloc=3MB (3925032B) native alloc=2MB (2284432B) free=1865KB (1909872B)
2019-08-30 15:59:28.080 27453-27453/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.081 27453-27453/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.081 27453-27453/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore2/1567151765411.apk --output-vdex-fd=66 --oat-fd=67 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore2/oat/arm/1567151765411.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:28.319 27453-27453/? I/dex2oat: dex2oat took 239.148ms (466.151ms cpu) (threads: 4) arena alloc=6KB (6864B) java alloc=620KB (635624B) native alloc=1138KB (1166240B) free=1421KB (1455200B)
2019-08-30 15:59:28.400 27458-27458/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.400 27458-27458/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.400 27458-27458/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_personal/1567151766654.apk --output-vdex-fd=67 --oat-fd=68 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_personal/oat/arm/1567151766654.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:28.668 27458-27458/? I/dex2oat: dex2oat took 268.957ms (584.370ms cpu) (threads: 4) arena alloc=17KB (17944B) java alloc=1096KB (1123232B) native alloc=1178KB (1207240B) free=1381KB (1414200B)
2019-08-30 15:59:28.753 27464-27464/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.753 27464-27464/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.754 27464-27464/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookshelfcard/1567151754443.apk --output-vdex-fd=68 --oat-fd=69 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookshelfcard/oat/arm/1567151754443.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.059 27464-27464/? I/dex2oat: dex2oat took 306.687ms (670.528ms cpu) (threads: 4) arena alloc=5KB (5656B) java alloc=1239KB (1268784B) native alloc=1208KB (1237064B) free=1351KB (1384376B)
2019-08-30 15:59:29.151 27469-27469/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:29.151 27469-27469/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:29.152 27469-27469/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginweb_search/1567151758977.apk --output-vdex-fd=69 --oat-fd=70 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginweb_search/oat/arm/1567151758977.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.368 27469-27469/? I/dex2oat: dex2oat took 217.446ms (407.470ms cpu) (threads: 4) arena alloc=4KB (4288B) java alloc=473KB (484984B) native alloc=965KB (989024B) free=1594KB (1632416B)
2019-08-30 15:59:29.444 27475-27475/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:29.444 27475-27475/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:29.445 27475-27475/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_common/1567151753366.apk --output-vdex-fd=70 --oat-fd=71 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_common/oat/arm/1567151753366.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.591 27475-27475/? I/dex2oat: dex2oat took 146.851ms (207.739ms cpu) (threads: 4) arena alloc=3KB (3792B) java alloc=303KB (310616B) native alloc=734KB (751968B) free=1313KB (1345184B)

发现一直再执行dex2oat!!! 花费了大概4S时间!

那这个应用层也可以想办法解决,比如后面让系统执行这个dex2oat,或者其他的。

总结:

    1.这篇文章只是给大家一个思路,第一次特别慢可能是dex2oat 导致 的!2.看log 的时候,别只看内容,要看下两个log 的打印相隔时间。

这篇关于android第一次启动超级慢的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1131028

相关文章

Android实现在线预览office文档的示例详解

《Android实现在线预览office文档的示例详解》在移动端展示在线Office文档(如Word、Excel、PPT)是一项常见需求,这篇文章为大家重点介绍了两种方案的实现方法,希望对大家有一定的... 目录一、项目概述二、相关技术知识三、实现思路3.1 方案一:WebView + Office Onl

Android实现两台手机屏幕共享和远程控制功能

《Android实现两台手机屏幕共享和远程控制功能》在远程协助、在线教学、技术支持等多种场景下,实时获得另一部移动设备的屏幕画面,并对其进行操作,具有极高的应用价值,本项目旨在实现两台Android手... 目录一、项目概述二、相关知识2.1 MediaProjection API2.2 Socket 网络

Android实现悬浮按钮功能

《Android实现悬浮按钮功能》在很多场景中,我们希望在应用或系统任意界面上都能看到一个小的“悬浮按钮”(FloatingButton),用来快速启动工具、展示未读信息或快捷操作,所以本文给大家介绍... 目录一、项目概述二、相关技术知识三、实现思路四、整合代码4.1 Java 代码(MainActivi

Android Mainline基础简介

《AndroidMainline基础简介》AndroidMainline是通过模块化更新Android核心组件的框架,可能提高安全性,本文给大家介绍AndroidMainline基础简介,感兴趣的朋... 目录关键要点什么是 android Mainline?Android Mainline 的工作原理关键

如何解决idea的Module:‘:app‘platform‘android-32‘not found.问题

《如何解决idea的Module:‘:app‘platform‘android-32‘notfound.问题》:本文主要介绍如何解决idea的Module:‘:app‘platform‘andr... 目录idea的Module:‘:app‘pwww.chinasem.cnlatform‘android-32

Android实现打开本地pdf文件的两种方式

《Android实现打开本地pdf文件的两种方式》在现代应用中,PDF格式因其跨平台、稳定性好、展示内容一致等特点,在Android平台上,如何高效地打开本地PDF文件,不仅关系到用户体验,也直接影响... 目录一、项目概述二、相关知识2.1 PDF文件基本概述2.2 android 文件访问与存储权限2.

Android Studio 配置国内镜像源的实现步骤

《AndroidStudio配置国内镜像源的实现步骤》本文主要介绍了AndroidStudio配置国内镜像源的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、修改 hosts,解决 SDK 下载失败的问题二、修改 gradle 地址,解决 gradle

Redis在windows环境下如何启动

《Redis在windows环境下如何启动》:本文主要介绍Redis在windows环境下如何启动的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Redis在Windows环境下启动1.在redis的安装目录下2.输入·redis-server.exe

解决SpringBoot启动报错:Failed to load property source from location 'classpath:/application.yml'

《解决SpringBoot启动报错:Failedtoloadpropertysourcefromlocationclasspath:/application.yml问题》这篇文章主要介绍... 目录在启动SpringBoot项目时报如下错误原因可能是1.yml中语法错误2.yml文件格式是GBK总结在启动S

在Android平台上实现消息推送功能

《在Android平台上实现消息推送功能》随着移动互联网应用的飞速发展,消息推送已成为移动应用中不可或缺的功能,在Android平台上,实现消息推送涉及到服务端的消息发送、客户端的消息接收、通知渠道(... 目录一、项目概述二、相关知识介绍2.1 消息推送的基本原理2.2 Firebase Cloud Me