How can I exclude unnecessary DLLs from my build?
There is another way of doing this:
Step 1: Right-click on the .apk file and Open it with WinRAR/ZIP
Step 2: Enter the assets folder, then enter bin\Data\Managed
Step 3: There you will find all the DLLs, just remove what you want (not that much :D)
Seems like there is not a direct way to do that. I just tried removing some dlls references on a test project and wasn't enough. Unity was including some of the removed libraries in the build anyway.
But, what if we make impossible to unity to find those elements? That approach worked.
Steps:
Remove references in Assembly-CSharp and Assembly-CSharp-firstpass
Follow the path and rename those removed dlls to something else, like
filename.dd_old
:
3.- Compile, Build, and see the results :)
Before:
Mono dependencies included in the build
Dependency assembly .....
Dependency assembly - UnityEngine.UI.dll
Dependency assembly - UnityEngine.Networking.dll
Dependency assembly - UnityEngine.SpatialTracking.dll
Dependency assembly .....
After:
Mono dependencies included in the build
Dependency assembly .....
Dependency assembly - UnityEngine.UI.dll
Dependency assembly - UnityEngine.SpatialTracking.dll
Dependency assembly .....
Test your game, I really don't know what can be wrong with this practice, and I mean, I really don't know what cannot go wrong with this practice :D
Rename the
_old
files to their original names for the next project, etc..
The Unity provides a feature to strip unused code, and therefore the dll, for you.
Follow the steps below:
- Select the menu Edit->Project Settings.
- In the Project Settings dialog box, select Player.
- In the Player select Other Settings.
- Scroll down until the Optimization section.
- Change the option Managed Striping Level in the dropdown list.
This feature has many options and you can even link the specific assemblies using a link.xml file in the Assets folder.
I strongly suggest to read the Unity official documentation Managed Code Stripping for further information.
That's it. Hope it helps.