Enable multiDex for Unity Project
When your app and the libraries it references exceed 65,536 methods, you encounter a build error that indicates your app has reached the limit of the Android build architecture. Find more here.
Unity 2017.4 and above
Using Unity 2017.4 and above you can enable multiDex without exporting your project. Please follow this steps to enable multiDex:
Switch to Gradle Build System
- Open File -> Build Settings... in Unity Editor.
- Select Android in platform list and click Switch Platform.
- Select Gradle (new) in Build System dropdown.
Configure Gradle Config
- Now open mainTemplate.gradle file in any text editor.
- Add multiDexEnabled true as a new line inside the defaultConfig object.
If your minSdkVersion is set to 20 or lower
- Open your main AndroidManifest.xml. It should be located in Assets/Plugins/Android/ folder. If you don't have it there just copy it from [unity_folder]/PlaybackEngines/AndroidPlayer/Apk/AndroidManifest.xml and change package name there to yours.
- Find application tag and add there one more line: android:name="android.support.multidex.MultiDexApplication"
- If you are using Unity 2018.2 or newer, add implementation 'com.android.support:multidex:1.0.1' as new line inside root dependencies object.
- If your Unity version is older, add compile 'com.android.support:multidex:1.0.1' as new line inside root dependencies object.