Java – Android compilation, too many methods

Android compilation, too many methods… here is a solution to the problem.

Android compilation, too many methods

When I compile my android package: it prints

Problems writing output: too many methods: 65544; maximum value is 65536. By package:

This is because I have too many local methods defined in my class. How do I fix this?

Solution

One solution proposed by Google is to use multiple DEX files.

http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html

According to my comment in another solution for Konstatin, in some cases you will run more than the allowed allocation of 64K methods.

Proguard’s removal of some third-party library method calls that you don’t use is a temporary solution.

Related Problems and Solutions