Android IL2CPP file size

Hi guys

I build a game for android with Mono2x setting and it file size is : 32.2MB , with no stripping and .NET 2.0 was used

But with a same source code I’m using setting with IL2CPP ( with stripping engine code and .NET 2.0 ) the file size increasing to 84.6 mb

So what happen with IL2CPP build file size ? or did I make some setting wrong ?

Thanks.

Which version of Unity are you using? Also there was a known bug with this build size but do not know if it got fixed…

Since Android/IL2CPP support is experimental now, the generated binary is not being stripped of symbols, so it is pretty large. You can export the project, and use the stripper from NDK manually. That stripping tool should be in this location on Windows.

android-ndk-r10e\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-strip.exe

1 Like

Do you know when things will progress, in Unity 5.4 or we see some changes in the patch releases?

Android/IL2CPP is still planned to be experimental in 5.4. The current information from the Android team is that it will be fully supported “when it is ready” so we don’t have a release in mind yet. It should appear on the public roadmap when we know though.

1 Like

Thanks for information :slight_smile:

Hello, I 'm trying to strip libil2cpp.so applying the command “arm-linux-androideabi-strip libil2cpp.so” and it reduces file size , but when I re-imported to the .apk file and run the application, the installation fails.

I wonder if it’s the right thing to do to reduce the size of apk

You should run the stripping prior to building the .apk.

Steps would be:

  • Export as Android Project
  • Import into Android Studio
  • Run stripping on required .so files (I do it on {my android studio project}/…/src/main/jniLibs/armeabi-v7a/*.so)
  • Clean project in Android Studio (may not be required, but feels good)
  • Build apk
1 Like

Thanks for the info , I followed the steps and the application is installed correctly, but when I try to open it instantly closes =(

What device type is this? There are some known issues that causes IL2CPP builds to fail to run on some devices, see my bug report here: https://fogbugz.unity3d.com/default.asp?756859_2lue8qeg6rgce21e

Could be related.

The device is a “Huawei Y330 (hwY330-U05)”. The compiled application without stripped works well (with unnecessary size), but when compiled in Android Studio, this stops working when the application starts

Have you tried building with Android studio but without the stripping? (Just trying to isolate where the issue arises).

We’re using Unity 5.4.1f1 and when switching to IL2CPP the apk filesilze increases from 68,4mb to 80,1mb.

Any hints or posts that could help us reduce the filesize again?

Ok, second try :slight_smile: Why really would like to release our update tomorrow with IL2CPP generated code but we won’t release a IL2CPP with this increase in filesize.

I’ve attached a screenshot with our build settings. These are the same for the Mono scripting backend.

IL2CPP often has a larger footprint, but gives a performance benefit at the cost of size. IMO this is a valuable trade off.

You’re building a ‘fat’ binary that contains both arm7 and x86 code. You can remove the x86 target and decrease the size.

Also note, you’re worried about a 12mb total increase in size. What is your reasoning for concern here? 68mb vs 80mb in my opinion is not significant enough to be concerned. I don’t believe any user would be concerned about 12mb on any device that can run a Unity 5 app.

We have bad experience with increased filesize as people complained when we updated from Unity 4.x to Unity 5.2.2 and the filesize increased by, I don’t know, 10mb. Now we’ve updated to Unity 5.4.1f1 und the app already increased by 3mb. Plus 12mb when compiling with IL2CPP is not cool.

I believe on Android when you compile for mono it produce a dll with commond intermediate language, so the same dll is used for x86 and arm.
When you compile with IL2CPP the same code is compiled first for arm then for x86, creating two executables specific for each architecture.
So with mono you are essentially deploying your code in another form which get interpreted on the fly, so you could target 100 architectures and it would still weight the same( if you don’t account for the interpreter size).
And that’s the reason people says Unity games without IL2CPP can be easily decompiled and they are practically an open book.
The increase in size cannot be avoided unless you make an apk for each platform.

Yes, guess so. Thanks for pointing that out.

Being able to strip more code and features would be great, especially for “2d” games that don’t need all the fancy stuff.

As I noted earlier, “You’re building a ‘fat’ binary that contains both arm7 and x86 code. You can remove the x86 target and decrease the size.”

So you can expect some increased size here.

You also say “Plus 12mb when compiling with IL2CPP is not cool.” - but you have not identified any actual ‘problem’ from this.

Being ‘cool’ or not is irrelevant. Compiling with IL2CPP gives faster performance and natural code obfuscation. I’d consider these to be FAR more cool than the lack of coolness of an increase of 12mb.

You’re not going to get the benefits of IL2CPP for free. There’s a cost associated with its use and that can include an increase in executable size (especially when you’re creating a FAT binary with both x86 and arm).

Do two builds, one for x86 and one for arm and deploy both versions through the Play Store (it supports such features).

I seriously think you mis-allocating your effort here, you’re worried about something that isn’t a problem (IMO) - unless you can explain what the problem is.

when i used IL2CPP my file Size increased from 40mb to 264mb.
with this filesize i cant even publish it to the google play store.

Build Report
Uncompressed usage by category (Percentages based on user generated assets only):
Textures 17.3 mb 7.0%
Meshes 0.0 kb 0.0%
Animations 222.2 kb 0.1%
Sounds 36.2 mb 14.6%
Shaders 961.3 kb 0.4%
Other Assets 193.4 mb 77.9%
Levels 0.0 kb 0.0%
Scripts 101.5 kb 0.0%
Included DLLs 0.0 kb 0.0%
File headers 143.2 kb 0.1%
Total User Assets 248.2 mb 100.0%
Complete build size 740.5 mb

i have no idea what “other assets” are, so if somebody knows i would really like to know