转换为Dalvik格式失败:无法执行dex:字段ID不在[0,0xffff]:65536中

时间:2015-07-24 19:28:25

标签: android eclipse android-studio dalvik dex

对于我的项目方法,计数是55K。显然低于65k的限制。当我尝试在eclipse / studio中运行app时,我正在

  

转换为Dalvik格式失败:无法执行dex:字段   ID 不在[0,0xffff]:65536

项目中包含5-6个库,我的应用程序也有很多功能。

在Google上我找到了许多链接 转换为Dalvik格式失败: 无法执行dex:方法ID ,而不是[0,0xffff]:65536 可能的multidex配置解决方案。

但如何修复>>> 字段ID不在[0,0xffff]中:65536 ????

1 个答案:

答案 0 :(得分:0)

You mention that your method count is 55K, which is indeed less than the 65K limit imposed by the dex format.

The error that you're seeing isn't related to the number of methods, however. Dex also limits you to 65K fields, i.e. instance variables. You seem to be hitting that limit. To fix it, you'll have to examine what in your app (and the libraries it uses) has so many fields.

I wrote a gradle plugin that will give you this info on every build. It's on github at https://github.com/KeepSafe/dexcount-gradle-plugin.