How to solve the issue with Dalvik compiler limitation on 64K methods?

北战南征 提交于 2019-11-27 18:10:40

Enable Proguard (http://developer.android.com/tools/help/proguard.html) to remove unused methods. The protobuf generator creates thousands of methods that are never actually used.

Micro-protobuffers (https://code.google.com/p/micro-protobuf/) may also be useful.

Square had similar issues and they built Wire to deal with the method explosion caused by protobufs. They claim to have killed 10,000 methods.

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

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

with these lines:

compile 'com.google.android.gms:play-services-fitness:6.5.87'
compile 'com.google.android.gms:play-services-wearable:6.5.87'

for more reference, you can click here

If this is the first use of Protocol buffers, you could look at alternative JavaME implementations i.e.

there are others listed in Third party add ons. If have not used any of them, but they seem to be smaller and do not have all the methods created by the standard protocol buffers.

We've recently added Nano Protobufs to Android which significantly reduces the number of methods generated.

If you are using eclipse this is the easiest work around Click Here!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!