# How do you actually build once you encounter the 'Too many method references' error?

I'm making a very simple mobile F2P arcade game in Unity After adding SDKs for facebook, gamesparks, firebase, and appodeal I coud not build, getting the "Too many method references: 76221; max is 65536" error.

The solution from Too many field references: 70613; max is 65536 is apparently to export an ADT project, import it into Android studio and go from there.

I built following these instructions, and after building my Android studio project had errors relating to the facebook SDK similar to here: Unity exporting android project with Facebook SDK issue

The solution proposed there is to copy all the .aar from your Unity project to files to the Android studio project and add lines to the build.gradle file referencing them, which I did.

After doing all that the 4 facebook related errors are gone but one new one appears:

Error: more than one library with package name 'android.support.v7.appcompat

A proposed solution for that is to search for the offending file and delete it in windows explorer but there is nothing with that name in my Android studio project folder. I tried removing some .aar files with appcompat in the name but I ended up reverting to the previous 5 facebook errors

This whole thing has been a bit of a nightmare and I have no idea what I am doing. I would love to hear from someone who encountered this error and got past it and was able to build their game again. Surely this must be a common issue for anyone making a commercial mobile game in Unity?

• So you basically hit the DEX method count limit (not Unity limit as in the linked question). The solution to this is to use fewer methods (no please don't write everything in one big method). You can reach this by either 1) using fewer libraries 2) strip out unused methods from libraries 3) multidex your application. I don't know how to do these in Unity. Not sure if unused methods are already stripped from libraries or not, or if it is possible at all in a Unity project. You basically need to look at proguard and if that is supported in Unity. Else export it as android project. – miva2 May 23 '17 at 13:45

## 1 Answer

I have not solved this. But I have bypassed it.

1. Appodeal have another SDK package with less methods

2. I removed parts of this appodeal SDK. They have libraries for each ad provider they use. I will un-register from the ad providers whose libraries I removed.

This way I was able to get the methods to under 65536, so I can build normally from Unity

• You actually solved it. As @miva2 already described in the comment it was not a unity limit but actually a DEX method count limit. Using fewer methods solves that problem :) – Nico Feb 14 '18 at 6:24