My team and I have inherited a large Android project from another team. The whole application with all the included libraries is reported to have around 35000 methods. We now have the task to implement a new service in the app where we need to use Protocol Buffers.
The problem is that the generated .jar file with all the required .proto files creates another couple of 35000 methods, that's 70000 methods. And if you are not aware, the Android compiler has a limitation of 65536 methods per .dex file. We are clearly over that limit and we are getting the following error trying to compile the app:
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
Yes, the application architecture should probably be restructured but that will take time. And for now we are trying to figure out a solution to work around this problem temporarily.
Any suggestions?
You can use another DEX file. This is how you do it:
http://android-developers.blogspot.co.il/2011/07/custom-class-loading-in-dalvik.html