Reputation: 623
I'm using Unity 2018.2.3 with .Net 4.6 Scripting Runtime.
I have two games. When I build with IL2CPP backend, apk size is always bigger than Mono backend.
First Game:
APK size With Mono: 12.9 MB
APK size with IL2CPP: 13.7 MB
Second Game:
APK size With Mono: 39 MB
APK size with IL2CPP: 45 MB
Why is this happening?
Upvotes: 3
Views: 2773
Reputation: 2329
This happens for a few reasons.
First, the Android build with Mono ships the managed assemblies in the APK. Those assemblies are just-in-time compiled to machine code on the Android device. IL2CPP, on the other hand, ahead-of-time compiles the managed assemblies into machine code, and ships the machine code in the APK. The IL byte code in those managed assemblies is more compact than machine code for two reasons:
Second, by default Unity generates machine code for both the ARMv7 and x86 architectures with IL2CPP. Since IL2CPP needs to generate that code ahead of time, all of the issues with larger code mentioned in the first point are duplicated. If you don't need to support x86, for example, you can modify the player settings to avoid building it.
Upvotes: 7