Android 应用程序首次启动需要更多时间,甚至需要 30 秒或更长时间
Android app launch first time launch is taking more time even some time 30 sec and more
以下是应用首次安装时的日志:
05-12 13:16:23.632 28250-28250/com.app.projectName W/System: ClassLoader referenced unknown path: /data/app/com.app.projectName-1/lib/arm
05-12 13:16:59.041 28250-28250/com.app.projectName W/System: ClassLoader referenced unknown path: /data/app/com.app.projectName-1/lib/arm
05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: VM with version 2.1.0 has multidex support
05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: install
05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: VM has multidex support, MultiDex support library is disabled.
而且我在我的项目中使用 MultiDex
库,它将完全低于棒棒糖之前的 devices.This 应用程序首次启动时在 Lollipop 设备中的延迟在 30 秒到 90 秒之间变化。
看看是不是MultiDex
的缘故吧?因为当时间为 1.) 初始化 05-12 13:16:23.632 并且第二个日志在 36 秒后出现,即 05-12 13:16:59 .041
那个东西造成应用程序延迟 ClassLoader
引用.... MultiDex
正在快速初始化。下面是屏幕截图 需要 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'
}
感谢任何帮助。
终于在 16 天后找到了答案,感谢你@Amir。正确答案是禁用即时 运行 然后 运行。新发布的 Android Studio 2.0 & 2.1 有一个奇怪的问题。首次启动应用程序比平时花费更长的时间此问题仅在调试模式下发生,不会影响您发布的 APK。
Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run
Settings/Preferences(Mac) → 构建、执行、部署 → 即时 运行 并取消选中即时 运行
我也遇到了同样的问题,终于解决了。
注:
1) 在生成 apk 文件之前取消选中所有这些选项以解决生产构建中的延迟问题。
2) 在您开发或添加新功能时,请将其保留为默认设置(即时 运行)以加快开发速度。
希望这能解决您的问题。
以下是应用首次安装时的日志:
05-12 13:16:23.632 28250-28250/com.app.projectName W/System: ClassLoader referenced unknown path: /data/app/com.app.projectName-1/lib/arm 05-12 13:16:59.041 28250-28250/com.app.projectName W/System: ClassLoader referenced unknown path: /data/app/com.app.projectName-1/lib/arm 05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: VM with version 2.1.0 has multidex support 05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: install 05-12 13:16:59.073 28250-28250/com.app.projectName I/MultiDex: VM has multidex support, MultiDex support library is disabled.
而且我在我的项目中使用 MultiDex
库,它将完全低于棒棒糖之前的 devices.This 应用程序首次启动时在 Lollipop 设备中的延迟在 30 秒到 90 秒之间变化。
看看是不是MultiDex
的缘故吧?因为当时间为 1.) 初始化 05-12 13:16:23.632 并且第二个日志在 36 秒后出现,即 05-12 13:16:59 .041
那个东西造成应用程序延迟 ClassLoader
引用.... MultiDex
正在快速初始化。下面是屏幕截图
我的 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'
}
感谢任何帮助。
终于在 16 天后找到了答案,感谢你@Amir。正确答案是禁用即时 运行 然后 运行。新发布的 Android Studio 2.0 & 2.1 有一个奇怪的问题。首次启动应用程序比平时花费更长的时间此问题仅在调试模式下发生,不会影响您发布的 APK。
Settings/Preferences(Mac) → Build, Execution, Deployment → Instant Run and uncheck Instant Run
Settings/Preferences(Mac) → 构建、执行、部署 → 即时 运行 并取消选中即时 运行
我也遇到了同样的问题,终于解决了。
注:
1) 在生成 apk 文件之前取消选中所有这些选项以解决生产构建中的延迟问题。
2) 在您开发或添加新功能时,请将其保留为默认设置(即时 运行)以加快开发速度。
希望这能解决您的问题。