简体   繁体   中英

Android App starting slow - dex2oat Zip is absent. Canceled - Gradle 2.10

I wrote an Android App which worked fine so far. Then I added the features for Google Cloud Messaging (GCM). I used the demo project from Google which seems to have added analytics and app indexing etc.

Now starting the app works as intended but takes a lot of time. The log shows many messages like this:

I/dex2oat: ----------------------------------------------------
I/dex2oat: <SS>: S T A R T I N G . . .
I/dex2oat: <SS>: Zip is absent. Canceled.
I/dex2oat: /system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm --instruction-set-features=div --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/world.b2g.b2gether/files/instant-run/dex/slice-com.google.android.gms-play-services-measurement-8.4.0_d76b40d326ea93493481fa158b18846c1c4627dd-classes.dex --oat-fd=29 --art-fd=-1 --oat-location=/data/data/world.b2g.b2gether/cache/slice-com.google.android.gms-play-services-measurement-8.4.0_d76b40d326ea93493481fa158b18846c1c4627dd-classes.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
I/dex2oat: dex2oat took 288.616ms (threads: 4)
I/dex2oat: ----------------------------------------------------
I/dex2oat: <SS>: S T A R T I N G . . .
I/dex2oat: <SS>: Zip is absent. Canceled.
I/dex2oat: /system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm --instruction-set-features=div --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/world.b2g.b2gether/files/instant-run/dex/slice-com.google.android.gms-play-services-maps-8.4.0_36e4d7c4ee371ae72ff4fba4383d7535cc7f3d3a-classes.dex --oat-fd=29 --art-fd=-1 --oat-location=/data/data/world.b2g.b2gether/cache/slice-com.google.android.gms-play-services-maps-8.4.0_36e4d7c4ee371ae72ff4fba4383d7535cc7f3d3a-classes.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
I/dex2oat: dex2oat took 321.095ms (threads: 4)
I/dex2oat: ----------------------------------------------------
I/dex2oat: <SS>: S T A R T I N G . . .
I/dex2oat: <SS>: Zip is absent. Canceled.
I/dex2oat: /system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm --instruction-set-features=div --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/world.b2g.b2gether/files/instant-run/dex/slice-com.google.android.gms-play-services-location-8.4.0_298f1e5056d6eea423c13052ef0c9136963ce27b-classes.dex --oat-fd=29 --art-fd=-1 --oat-location=/data/data/world.b2g.b2gether/cache/slice-com.google.android.gms-play-services-location-8.4.0_298f1e5056d6eea423c13052ef0c9136963ce27b-classes.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
I/dex2oat: dex2oat took 298.720ms (threads: 4)
I/dex2oat: ----------------------------------------------------
...

It appears as if some packages are missing. Since I don't need any of these features (except for maps and GCM) I deactivated the options for Analytics, Authentication... in Android Studio . Yet, these messages still appear.

Could this be because I apply the services in the build.gradle file?

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/greendao-2.1.0.jar')
    compile project(':volley')
    compile 'com.android.support:support-v13:23.3.0'
    compile 'com.android.support:recyclerview-v7:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
}

apply plugin: 'com.google.gms.google-services'

In the app gradle config I also wrote

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0'
        classpath 'com.google.gms:google-services:2.0.0'
    }
}

-------------------------- EDIT : --------------------------

Turns out it seems to be gradle's fault

I traced the problem a bit back to the point when I updated to the new Android Studio. At one point I had to switch from Gradle 2.8 to Gradle 2.10 . If I change it to Gradle 2.8 this problem is gone. Unfortunately Android Studio tells me I have to update to 2.10 now.

So what can I do?

----------------------- EDIT 07.June.2016 : -----------------------

It looks like with the new update to Android Studio 2.1.2 this bug is fixed (or at least I don't see this message any more)

Finally I found the answer. The problem was really Gradle. But not the new version itself. Much more the instand build.

What I learned:

Problem seems to be that with the enabled Instant Run some "slices" for frameworks can't be found. This also affects the phone when running the app independently from the compiler (eg starting if via the App Drawer). It appears as if the already compiled libraries have to be searched/linked/compiled again. The reason this happens only with Gradle 2.10 or higher was not the version itself but merely that Gradle 2.8 doesn't support the new feature.

The Solution:

For now the best work around was to deactivate this funcionality in:

Settings/Build, Execution, Deployment/Instant Run -> Enable Instant Run to hot swap code

>> EDIT: Still the update to Android Studio 2.1 doesn't seem to fix this problem to me.

在此输入图像描述

I also run into this problem. My app's loading speed is too slow. I checked the logcat below. I/dex2oat: dex2oat took 288.616ms After I unchecked the option box that the writer mentioned the problem has solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM