【问题标题】:What does this error mean in android studio? [duplicate]这个错误在android studio中是什么意思? [复制]
【发布时间】:2017-07-19 17:08:40
【问题描述】:

我对如何在 android studio 中使用谷歌地图很感兴趣。我按照教程进行了三次检查,确认所有内容都输入正确,但是当我尝试构建 apk 时,出现此错误:

错误:任务':app:transformClassesWithDexForDebug'的执行失败。> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com .android.dex.DexIndexOverflowException:方法 ID 不在 [0, 0xffff] 中:65536

【问题讨论】:

  • 表示编译后的代码里面的方法太多了。尝试使用 DexIndexOverflowException 进行互联网搜索...同时使用 DexIndexOverflowException 和 google play 服务进行互联网搜索会返回更有趣的结果...

标签: java android


【解决方案1】:

我对如何在 android studio 中使用谷歌地图很感兴趣

使用这个

compile 'com.google.android.gms:play-services-maps:10.2.0'

而不是这个

compile 'com.google.android.gms:play-services:10.2.0'

如果您想要更多的 Google Play 服务而不仅仅是地图 see here

如果你去那里,请阅读

(强调我的)

如果您的应用中的方法引用数量超过 65K 限制,您的应用可能无法编译。在编译应用时,您可以通过仅指定应用使用的特定 Google Play 服务 API 而不是所有这些 API 来缓解此问题

【讨论】:

    【解决方案2】:

    确保您只添加您正在使用的 google play services api。在你的情况下,你只需要地图,所以使用这个:

    com.google.android.gms:play-services-maps:10.2.0
    

    而不是添加整个包。第二个选项是启用多 dex。使用链接:https://developer.android.com/studio/build/multidex.html 获取有关启用多 dex 的信息。

    【讨论】:

      猜你喜欢
      • 2015-07-05
      • 2016-03-24
      • 2015-10-27
      • 1970-01-01
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多