This answer relies heavily on Android's official documentation (the quoted parts, specifically).
How to setup Multidex Support for Unity Project
What is Multidex: Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multi dex configuration.
Android application (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multi dex configuration.
When we exceed the total number of methods that can be referenced within a single DEX file to 65,536- including Android framework methods, library methods and methods in your own code. Avoid the 64K limit: Before configuring your app to enable the use of 64k or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or including libraries.
The following steps will help you to avoid or reduce this issue, keep patience.
Avoid the 64K limit
Step 1:
Build an Android Project from your Unity Editor.

Before configuring your app to enable use of 64K or more method references, you should take steps to reduce the total number of references called by your app code, including methods defined by your app code or included libraries. The following strategies can help you avoid hitting the DEX reference limit:
Step 2: Import your Android Project in Android Studio.
Review your app's direct and transitive dependencies - Ensure any large library dependency you include in your app is used in a manner that outweighs the amount of code being added to the app. A common anti-pattern is to include a very large library because a few utility methods were useful. Reducing your app code dependencies can often help you avoid the DEX reference limit.
Remove unused code with ProGuard - Enable code shrinking to run ProGuard for your release builds. Enabling shrinking ensures you are not shipping unused code with your APKs.
Step 3:
Setting up Aside from these official tips, when building your appUnity project to use a multi dex configuration requires that your make the following modification.
For minSdkVersion >= 21
All you need to do is set multiDexEnabled to true in the Main-Project build.Gradle file:
For minSdkVersion is <=20, then you must use the multi dex support library as follows:
Modify the Main_Project build.Gradle file to enable multi dex and add the multi dex library as a dependency:

Step 4: If you override the Application class, perform one of the following: If you do not override the Application class, edit your Main manifest file to set android: name in the tag as follows:
Paste these entries in your java class:
package com.DemoProj.DemoApplication;
import android.app.Application;
import android.support.multidex.MultiDexApplication;
public class DemoApplication extends MultiDexApplication {
public DemoApplication() {
try {
} catch (Exception e) {
}
}
}
Now add the class in your Main manifest:
Add android:name=".your Java class name"
and now add android:allowBackup = "true"
inside your main manifest application tag.

Step 5: Check error form other plugins manifest and clean the project.And sysc again.
Step 6: If there is any dependency issue is still there in your project run this command in Android Terminal Gradle clean App."App name" and press enter.
Step 7: Copy these dependency in your Application Gradle , under dependencies: compile fileTree(include: ['.jar'], dir: 'bin') compile fileTree(include: ['.jar'], dirsteps will help you further: 'libs')
Step 8:
Add the signingConfig in your main projects Gradle.
Or set the Signing mode to Debug mode by manually,
Go to File-> Project Structure -> Under Modules Click on your project and under Build Types select Debug ->choose Signing Config-> debug

Now sync your Gradle and build the project.
Build an Android Project from your Unity Editor.

Import your Android Project in Android Studio.

Setting up your app project to use a multi dex configuration requires that your make the following modification.
If your minSdkVersion is set to 21 or higher, all you need to do is set
multiDexEnabledtotruein your module-level build.gradle file, as shown here:android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 26 multiDexEnabled true } ... }However, if your
minSdkVersionis set to 20 or lower, then you must use the multidex support library as follows:3.1. Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android { defaultConfig { ... minSdkVersion 15 targetSdkVersion 26 multiDexEnabled true } ... } dependencies { compile 'com.android.support:multidex:1.0.1' }3.2. Depending on whether you override the Application class, perform one of the following:
- If you do not override the
Applicationclass, edit your manifest file to setandroid:namein the<application>tag as follows:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <application android:name="android.support.multidex.MultiDexApplication" > ... </application> </manifest>- If you do override the
Applicationclass, change it to extend MultiDexApplication (if possible) as follows:
public class MyApplication extends MultiDexApplication { ... }- Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:
public class MyApplication extends SomeOtherApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } }- If you do not override the
Check error form other plugins manifest and clean the project.And sysc again.
If there is any dependency issue in your project, run this command in Android Terminal
% Gradle clean App."App name"Copy these dependency in your Application Gradle , under dependencies:
compile fileTree(include: ['*.jar'], dir: 'bin') compile fileTree(include: ['*.jar'], dir: 'libs')Add the signingConfig in your main projects Gradle.
Or set the Signing mode to Debug mode by manually, Go to File -> Project Structure -> Under Modules Click on your project and under Build Types select Debug ->choose Signing Config-> debug
Now sync your Gradle and build the project.
