android 无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536 即使 Multidex.jar

android Unable to execute dex: method ID not in [0, 0xffff]: 65536 even with Multidex.jar

在我的应用程序中,我添加了 appcompat-v7 lib 项目和 google-play-services(需要地图和驱动器 api)lib 项目。还有一些在应用程序中执行我的菜单功能所必需的库。

使用的库:

启动时出现错误“无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536 转换为 Dalvik 格式失败:无法执行 dex:方法 ID 不在 [0, 0xffff] 中:65536"

注意:我曾尝试在 libs 中为前棒棒糖设备添加 Multidex.jar,但没有成功

这可能是因为库中的方法有 65K 的引用限制。您使用的是整个 Google Play Services 库还是根据您的需要分离其功能的紧凑版本:

查看 Table 1 在 https://developer.android.com/google/play-services/setup.html

这样对于地图和驱动器,您将拥有三个库:

  • Google 播放服务核心
  • Google 播放服务地图
  • Google 播放服务驱动器

并且不必担心拥有不需要的东西,例如 Google 健身或 Google 钱包

注意:如果您在没有包含 Google Play Service 核心的情况下包含库,它将自动包含,因此您无需担心。