In Android development, we may import third-party jar packages, as Android projects grow, imported third-party jar packages will be more, this time, it is likely to encounter the problem of Project compilation packaging failure, is the Android 65k method limit. The error log is as follows
Error:execution failed for task ': Ttt:transformclasseswithdexfordebug '. Com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: Java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:method ID not in [0, 0xFFFF]: 65536
What is a 65k problem? In fact, it is very simple, Android has a limit, each App can only have a maximum of 65,536 functions.
The solution is the Multidex support library, because Android's IDE is basically Android studio, so here's just a workaround on as. First import this library Multidex support library. Then set the Build.gradle in the module
Android { ... Defaultconfig { ... multidexenabled True }}
Then let your application class inherit from the Multidexapplication class, for example:
public class MyApplication extends Multidexapplication { ...}
If it is not convenient to modify the inheritance (for example, has inherited the other encapsulated application) so long a little more complicated, overloaded Attachbasecontext, the code is as follows:
@Overrideprotected void Attachbasecontext (context base) { Super.attachbasecontext (context); Multidex.install (this);}
Then in the Androidmainfest file, modify the application to MyApplication, and then compile the package successfully, at this point, 65k problem solved.
Android Fix 65536 limit