Android应用程序首次启动启动需要花费更多时间甚至30秒甚至更长时间

时间:2016-05-12 07:52:03

标签: android delay multidex

以下是应用首次安装时的日志:

  

05-12 13:16:23.632 28250-28250 / com.app.projectName W / System:ClassLoader引用未知路径:/data/app/com.app.projectName-1/lib/arm   05-12 13:16:59.041 28250-28250 / com.app.projectName W / System:ClassLoader引用未知路径:/data/app/com.app.projectName-1/lib/arm   05-12 13:16:59.073 28250-28250 / com.app.projectName I / MultiDex:版本为2.1.0的VM具有multidex支持   05-12 13:16:59.073 28250-28250 / com.app.projectName I / MultiDex:安装   05-12 13:16:59.073 28250-28250 / com.app.projectName I / MultiDex:VM具有multidex支持,MultiDex支持库被禁用。

我在我的项目中使用MultiDex库它将完全在棒棒糖前设备下工作。这个延迟在Lollipop设备中在应用程序首次启动时在30秒到90秒之间变化。

看到它不是MultiDex对吗?因为时间是1.)初始化 05-12 13:16:23.632 ,第二次登录是在36秒之后, 05-12 13:16:59.041

该内容会创建引用的推文ClassLoader .... MultiDex正在快速初始化。下面是屏幕截图enter image description here它需要15秒到30秒,有时甚至更长。

我的Gradle文件是:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'

compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'org.apache.httpcomponents:httpcore:4.2.4'
compile 'org.apache.httpcomponents:httpmime:4.3'
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.1.2'
compile 'co.lujun:androidtagview:1.0.2'

compile 'com.google.android.gms:play-services-analytics:9.0.1'
compile 'com.google.android.gms:play-services-auth:9.0.1'
compile 'com.google.android.gms:play-services-plus:9.0.1'
compile 'com.google.android.gms:play-services-gcm:9.0.1'
compile 'com.google.android.gms:play-services-maps:9.0.1'
compile 'com.google.android.gms:play-services-location:9.0.1'
compile 'org.solovyev.android.views:linear-layout-manager:0.5@aar'
compile 'org.apache.commons:commons-lang3:3.0'

compile 'jp.wasabeef:picasso-transformations:2.0.0'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.greysonparrelli.permiso:permiso:0.2.0'
compile 'com.github.lawloretienne:imagegallery:0.0.14'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.github.mahmed8003:DroidValidatorLight:1.0.0'
compile 'com.android.support:palette-v7:23.4.0'
compile 'com.yalantis:ucrop:1.1.+'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.jakewharton:butterknife:7.0.1'
}

任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:18)

终于在16天之后找到答案了,谢谢你@Amir。正确的答案是禁用即时运行然后运行。新发布的Android Studio 2.0& 2.1。第一次启动应用程序需要比平时更长的时间,此问题仅在调试模式下发生,并且不会影响您发布的APK。

Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run

答案 1 :(得分:4)

设置/偏好设置(Mac)→构建,执行,部署→即时运行并取消选中即时运行

enter image description here

我也遇到了同样的问题,最后我解决了这个问题。
注意:
1)在生成apk文件之前,取消选中所有这些选项以解决生产版本中的延迟问题。

2)在开发或添加新功能时,请将其保留为默认设置(即时运行),以加快开发速度。

我希望这能解决您的问题。

相关问题