Player Settings…
Scripting Runtime Version: .NET 4.x Equivalent
Scripting Backend: Mono
Api Compatibility Level: .NET 4.x
Target Architectures: ARMv7 & x86
I have unzipped the APK and found a few interesting things…
The files in lib/ have all increased in size slightly (libunity.so gone from 22.6mb to 24mb), but I’m guessing this is to be expected.
The file assets/bin/data/unity default resources has gone from 0.7mb to 3.4mb.
The files in assets/bin/data/Managed/ used to contain all my plugin dll and 3 unity dll’s, all of which I use in my game (UnityEngine, UnityEngine.Networking and UnityEngine.UI). But now it contains 57 extra UnityEngine dll’s, all things that I don’t use (UnityEngine.VRModule, UnityEngine.TerrainModule, etc…).
If there is anything there that stands out as to why my build size is increasing I would appreciate suggestions. I have tried changing around the build/player settings, but I have yet to get the size down to an acceptable amount to submit to the google play store (Max 105mb).
on unity 2018.1.0f2, when i try to build android il2cpp to deal with this issue, clang never completes. it has been running for over 24 hours. I have tried reimporting everything…
Sorry for the delay in replying, I have been away so haven’t been able to try any suggestions until now.
LZ4HC - didn’t reduce the size at all.
mscorlib - Reduced the size by 1.7mb. Seems to have removed some of the unused dlls from assets/bin/data/Managed/ but not all (e.g VehiclesModule.dll has been stripped but ARModule.dll and some others I don’t use remain).
So even with mscorlib enabled, my apk size is still 12.8mb bigger when built with v2018.1.0f2 compared to v5.6.5f1.
I think at this point I will need to resort to doing another optimisation pass of the project assets to make up the gain in size if I wish to keep using 2018.
I’m also interested in build size issues.
Switching build configuration to IL2CPP increases build size by 10 MBs. And I would like to hear the reason by someone who has experience in this field.
Just like .Net 3.x has ‘2.0 Subset’, the ‘Standard 2.0’ is essentially lighter .NET 4.x.
The smaller .NET Standard profile will be default at 2018.3 and is our recommended profile for users to target as it
a) exposes a portable/sane set of .NET APIs
b) results in smaller builds.
Although do test on the build and not in the Editor as Editor code always runs against the full profiles: .NET 2.0 with old mono and .NET 4.x with new mono.
Also, while I am not very familiar with the publishing process, maybe splitting ARMv7 and x86 is possible?
Here are some numbers from an absolutely empty new project
.NET4.x - 25 449KB
.NET4.x Standard 2.0 - 24 683KB
.NET4.x Standard 2.0 mscorlib - 21 544KB (Stripping level - mscorlib, but results are very similar on all levels)
.NET4.x Standard 2.0 ‘Strip Engine Code’* IL2CPP - 14 285KB (ARMv7 and x86)
.NET4.x Standard 2.0 mscorlib ARM - 11 055KB (Only ARMv7 build)
Also note that the last few months have seen a good bit of active development from our team on code size issues related to the new scripting runtime and the larger .NET profiles. Our goal is to have no regression in size for projects that switch from the old scripting runtime (using either profile) to the new scripting runtime using the .NET Standard 2.0 profile on the same version of Unity.
For the 2018.2 beta, we’ve tested a number of full projects, and we are about 1-2% larger with the new scripting runtime. We’re expecting to close that gap in 2018.3.
Note that there is still generally some size increase in the Unity engine code from one release to another. This is independent of the scripting runtime code size improvement we are making, but it is something we understand and want to correct (one problem at a time though).
@JoshPeterson - We were at roughly the same size from 2017.4 to 2018.1, but we noticed that we had lost x86 support in the upgrade. Once I turned that on, the build increased from ~85MB to ~115MB, which puts us over the Google 100MB limit for uploads to Google Play without expansion files.
I have the same issue on 2018.3. My apk file size increased from 96MB to 112MB today and exceeded the 100MB limit of Google Play. I was using 2018.3 to build my game yesterday, it was 96MB. But today after only changing a few lines of my code, when I wanted to build the apk, Unity told me that the android sdk is not installed, in the build setting window, it told me to download the sdk, which was not true, I had installed the sdk properly a long time ago. So I restarted Unity, I opened the build setting window again, everything went to normal, I could build the apk as usual. But after building the apk, the apk file size increased suddenly. I had no clue what happened.
For me, the few kB’s aren’t really the biggest issue. The networking requirement is. Also, I’ve exported the Gradle project to Android studio to look into it more.
As an added thought, I’ve just looked at the build log. I have one empty scene. As in I opened a new scene, saved it and only added that scene to the build. This came out in the build report;
I know for a fact those last two scripts are not used. They are not in the scene, they are still in the build log. What determines if an Asset is ‘used’ seems to be the question now.