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

相关文章

SpringBoot启动报错的11个高频问题排查与解决终极指南

《SpringBoot启动报错的11个高频问题排查与解决终极指南》这篇文章主要为大家详细介绍了SpringBoot启动报错的11个高频问题的排查与解决,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一... 目录1. 依赖冲突:NoSuchMethodError 的终极解法2. Bean注入失败:No qu

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现

一文带你了解SpringBoot中启动参数的各种用法

《一文带你了解SpringBoot中启动参数的各种用法》在使用SpringBoot开发应用时,我们通常需要根据不同的环境或特定需求调整启动参数,那么,SpringBoot提供了哪些方式来配置这些启动参... 目录一、启动参数的常见传递方式二、通过命令行参数传递启动参数三、使用 application.pro

SpringBoot项目启动报错"找不到或无法加载主类"的解决方法

《SpringBoot项目启动报错找不到或无法加载主类的解决方法》在使用IntelliJIDEA开发基于SpringBoot框架的Java程序时,可能会出现找不到或无法加载主类com.example.... 目录一、问题描述二、排查过程三、解决方案一、问题描述在使用 IntelliJ IDEA 开发基于

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的

SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法

《SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法》本文主要介绍了SpringBoot项目启动错误:找不到或无法加载主类的几种解决方法,具有一定的参考价值,感兴趣的可以了解一下... 目录方法1:更改IDE配置方法2:在Eclipse中清理项目方法3:使用Maven命令行在开发Sprin

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问