Android: my application is too large and gives “Unable to execute dex: method ID not in [0, 0xffff]: 65536”?

前端 未结 8 1878
慢半拍i
慢半拍i 2020-11-27 04:52

I am trying to integrate my application with Box, Dropbox, and Google Drive. All 3 of these services require a number of 3rd party jars. Additionally, my application alrea

相关标签:
8条回答
  • 2020-11-27 05:08

    Most of the problems with hitting the 65k method limit are related with the use of the mastodontic Google Play Services in your apps. Recently, you can get more granularity when using it.

    Following this guide, you can use only parts that you want. Probably this will fix the problem, avoiding some black-magic tricks, or using multiDex. For example, if you only want Google Maps in your app (and you aren't using ads, wallet, google wear, analytics, etc...), using the entire dependency is a waste of time/space. You can use it that way:

    compile com.google.android.gms:play-services-base:6.5.87
    compile com.google.android.gms:play-services-maps:6.5.87
    

    You can read the entire list of "parts" in this link

    0 讨论(0)
  • 2020-11-27 05:10

    The Dalvik VM can have a maximum of 65536 methods per dex file, due to the bytecode instruction set not having a way to refer to method numbers requiring more than 16 bits (as pointed out by @danfuzz in the comments).

    While it is possible to fix this using multiple dex files, Facebook found another fix that they could deploy within their app to get around the problem.

    0 讨论(0)
提交回复
热议问题