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

相关文章

MySQL数据库宕机,启动不起来,教你一招搞定!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)公众号:老苏畅谈运维欢迎关注本人公众号,更多精彩与您分享。 MySQL数据库宕机,数据页损坏问题,启动不起来,该如何排查和解决,本文将为你说明具体的排查过程。 查看MySQL error日志 查看 MySQL error日志,排查哪个表(表空间

springboot3打包成war包,用tomcat8启动

1、在pom中,将打包类型改为war <packaging>war</packaging> 2、pom中排除SpringBoot内置的Tomcat容器并添加Tomcat依赖,用于编译和测试,         *依赖时一定设置 scope 为 provided (相当于 tomcat 依赖只在本地运行和测试的时候有效,         打包的时候会排除这个依赖)<scope>provided

Android实现任意版本设置默认的锁屏壁纸和桌面壁纸(两张壁纸可不一致)

客户有些需求需要设置默认壁纸和锁屏壁纸  在默认情况下 这两个壁纸是相同的  如果需要默认的锁屏壁纸和桌面壁纸不一样 需要额外修改 Android13实现 替换默认桌面壁纸: 将图片文件替换frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.*  (注意不能是bmp格式) 替换默认锁屏壁纸: 将图片资源放入vendo

内核启动时减少log的方式

内核引导选项 内核引导选项大体上可以分为两类:一类与设备无关、另一类与设备有关。与设备有关的引导选项多如牛毛,需要你自己阅读内核中的相应驱动程序源码以获取其能够接受的引导选项。比如,如果你想知道可以向 AHA1542 SCSI 驱动程序传递哪些引导选项,那么就查看 drivers/scsi/aha1542.c 文件,一般在前面 100 行注释里就可以找到所接受的引导选项说明。大多数选项是通过"_

Android平台播放RTSP流的几种方案探究(VLC VS ExoPlayer VS SmartPlayer)

技术背景 好多开发者需要遴选Android平台RTSP直播播放器的时候,不知道如何选的好,本文针对常用的方案,做个大概的说明: 1. 使用VLC for Android VLC Media Player(VLC多媒体播放器),最初命名为VideoLAN客户端,是VideoLAN品牌产品,是VideoLAN计划的多媒体播放器。它支持众多音频与视频解码器及文件格式,并支持DVD影音光盘,VCD影

用命令行的方式启动.netcore webapi

用命令行的方式启动.netcore web项目 进入指定的项目文件夹,比如我发布后的代码放在下面文件夹中 在此地址栏中输入“cmd”,打开命令提示符,进入到发布代码目录 命令行启动.netcore项目的命令为:  dotnet 项目启动文件.dll --urls="http://*:对外端口" --ip="本机ip" --port=项目内部端口 例: dotnet Imagine.M

Linux服务器Java启动脚本

Linux服务器Java启动脚本 1、初版2、优化版本3、常用脚本仓库 本文章介绍了如何在Linux服务器上执行Java并启动jar包, 通常我们会使用nohup直接启动,但是还是需要手动停止然后再次启动, 那如何更优雅的在服务器上启动jar包呢,让我们一起探讨一下吧。 1、初版 第一个版本是常用的做法,直接使用nohup后台启动jar包, 并将日志输出到当前文件夹n

android-opencv-jni

//------------------start opencv--------------------@Override public void onResume(){ super.onResume(); //通过OpenCV引擎服务加载并初始化OpenCV类库,所谓OpenCV引擎服务即是 //OpenCV_2.4.3.2_Manager_2.4_*.apk程序包,存

衡石分析平台使用手册-单机安装及启动

单机安装及启动​ 本文讲述如何在单机环境下进行 HENGSHI SENSE 安装的操作过程。 在安装前请确认网络环境,如果是隔离环境,无法连接互联网时,请先按照 离线环境安装依赖的指导进行依赖包的安装,然后按照本文的指导继续操作。如果网络环境可以连接互联网,请直接按照本文的指导进行安装。 准备工作​ 请参考安装环境文档准备安装环境。 配置用户与安装目录。 在操作前请检查您是否有 sud

SpringBoot项目是如何启动

启动步骤 概念 运行main方法,初始化SpringApplication 从spring.factories读取listener ApplicationContentInitializer运行run方法读取环境变量,配置信息创建SpringApplication上下文预初始化上下文,将启动类作为配置类进行读取调用 refresh 加载 IOC容器,加载所有的自动配置类,创建容器在这个过程