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 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

Android里面的Service种类以及启动方式

《Android里面的Service种类以及启动方式》Android中的Service分为前台服务和后台服务,前台服务需要亮身份牌并显示通知,后台服务则有启动方式选择,包括startService和b... 目录一句话总结:一、Service 的两种类型:1. 前台服务(必须亮身份牌)2. 后台服务(偷偷干

Windows设置nginx启动端口的方法

《Windows设置nginx启动端口的方法》在服务器配置与开发过程中,nginx作为一款高效的HTTP和反向代理服务器,被广泛应用,而在Windows系统中,合理设置nginx的启动端口,是确保其正... 目录一、为什么要设置 nginx 启动端口二、设置步骤三、常见问题及解决一、为什么要设置 nginx

springboot启动流程过程

《springboot启动流程过程》SpringBoot简化了Spring框架的使用,通过创建`SpringApplication`对象,判断应用类型并设置初始化器和监听器,在`run`方法中,读取配... 目录springboot启动流程springboot程序启动入口1.创建SpringApplicat

树莓派启动python的实现方法

《树莓派启动python的实现方法》本文主要介绍了树莓派启动python的实现方法,文中通过图文介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录一、RASPBerry系统设置二、使用sandroidsh连接上开发板Raspberry Pi三、运

Android kotlin语言实现删除文件的解决方案

《Androidkotlin语言实现删除文件的解决方案》:本文主要介绍Androidkotlin语言实现删除文件的解决方案,在项目开发过程中,尤其是需要跨平台协作的项目,那么删除用户指定的文件的... 目录一、前言二、适用环境三、模板内容1.权限申请2.Activity中的模板一、前言在项目开发过程中,尤

SpringBoot项目启动后自动加载系统配置的多种实现方式

《SpringBoot项目启动后自动加载系统配置的多种实现方式》:本文主要介绍SpringBoot项目启动后自动加载系统配置的多种实现方式,并通过代码示例讲解的非常详细,对大家的学习或工作有一定的... 目录1. 使用 CommandLineRunner实现方式:2. 使用 ApplicationRunne

Android数据库Room的实际使用过程总结

《Android数据库Room的实际使用过程总结》这篇文章主要给大家介绍了关于Android数据库Room的实际使用过程,详细介绍了如何创建实体类、数据访问对象(DAO)和数据库抽象类,需要的朋友可以... 目录前言一、Room的基本使用1.项目配置2.创建实体类(Entity)3.创建数据访问对象(DAO

bat脚本启动git bash窗口,并执行命令方式

《bat脚本启动gitbash窗口,并执行命令方式》本文介绍了如何在Windows服务器上使用cmd启动jar包时出现乱码的问题,并提供了解决方法——使用GitBash窗口启动并设置编码,通过编写s... 目录一、简介二、使用说明2.1 start.BAT脚本2.2 参数说明2.3 效果总结一、简介某些情

Android WebView的加载超时处理方案

《AndroidWebView的加载超时处理方案》在Android开发中,WebView是一个常用的组件,用于在应用中嵌入网页,然而,当网络状况不佳或页面加载过慢时,用户可能会遇到加载超时的问题,本... 目录引言一、WebView加载超时的原因二、加载超时处理方案1. 使用Handler和Timer进行超