我写了一个Android应用程序,到目前为止工作正常。 然后我添加了Google Cloud Messaging(GCM)的功能。我使用了谷歌的演示项目,该项目似乎增加了分析和应用程序索引等。
现在启动应用程序按预期工作但需要花费大量时间。日志显示了许多这样的消息:
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: ----------------------------------------------------
...
看起来好像有些包丢失了。 由于我不需要任何这些功能(地图和GCM除外),因此我在Android Studio中停用了Analytics,Authentication ...的选项。然而,这些信息仍然出现。
这可能是因为我在build.gradle文件中应用服务吗?
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'
在app gradle配置中我也写了
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:2.0.0'
}
}
--------------------------编辑:---------------- ----------
原来这似乎是gradle的错误
当我更新到新的Android Studio时,我将问题追溯到了一点。有一次我不得不从 Gradle 2.8 切换到 Gradle 2.10 。如果我将其更改为Gradle 2.8,则问题就消失了。不幸的是Android Studio告诉我现在必须更新到2.10。
那我该怎么办?
-----------------------编辑07.June.2016:-------------- ---------
看起来Android Studio 2.1.2的新更新已修复此错误(或者至少我不再看到此消息)
答案 0 :(得分:11)
最后我找到了答案。这个问题真的是Gradle。 但不是新版本。更多的instand构建。
我学到了什么:
问题似乎是启用即时运行一些&#34;切片&#34;对于框架,无法找到。当独立于编译器运行应用程序时,这也会影响手机(例如,通过App Drawer启动)。 似乎必须再次搜索/链接/编译已编译的库。 仅在Gradle 2.10或更高版本中出现这种情况的原因不是版本本身,而仅仅是Gradle 2.8不支持新功能。
解决方案:
目前最好的解决办法是停用这个功能:
设置/构建,执行,部署/即时运行 - &gt;启用“即时运行”以热插拔代码
&GT;&GT;编辑: Android Studio 2.1的更新似乎无法解决这个问题。
答案 1 :(得分:-1)
我也遇到了这个问题。 我的应用加载速度太慢了。 我检查了下面的logcat。 I / dex2oat:dex2oat耗时288.616ms 在我取消选中作者提到的问题已解决的选项框之后。