I would recommend you to not change anything else, untill you get to understand what it does. So as you can see default gradle version that unity is supporting is 2.1.0. For this reason only I suggested Android studio 2.3.3.

v) Adding Multidex support in template gradle.

Let’s include multidex in out gradle template. In dependencies just add following line before **DEPS**

Conclusion

That’s all you need to do to enable multidex support in unity using gradle.

There are few things worth mentioning.

If you guys have noticed we have included multidex dependency twice (why?). I believe that should not be an issue, gradle will take care of it.

Official statement by Unity for multidex enabling is still NO.

Although it solves multidex issue, working and fixing gradle issues still requires good amount of knowledge.

The good part is you don’t have to export your project again and again, you can directly build multidex game from unity itself.

Update: -

Unity 2018 or later now directly provides option to override mainTemplate.gradle. You can enable it by going File->Build Settings->Player Settings in Mac. Go to Publishing Settings and tick “Custom Gradle Template”. You will be able to see mainTemplate.gradle in your Plugins/Android folder.