Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Android IL2CPP file size

Discussion in 'Android' started by BrokenAngel, Jan 12, 2016.

  1. BrokenAngel

    BrokenAngel

    Joined:
    Mar 24, 2013
    Posts:
    92
    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.
     
  2. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    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..
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    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
     
    MrEsquire likes this.
  4. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Do you know when things will progress, in Unity 5.4 or we see some changes in the patch releases?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    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.
     
    TimLOM likes this.
  6. BrokenAngel

    BrokenAngel

    Joined:
    Mar 24, 2013
    Posts:
    92
    Thanks for information :)
     
  7. leoncorrl

    leoncorrl

    Joined:
    Apr 27, 2014
    Posts:
    15
    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
     
  8. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    You should run the stripping prior to building the .apk.

    Steps would be:

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

    leoncorrl

    Joined:
    Apr 27, 2014
    Posts:
    15
    Thanks for the info , I followed the steps and the application is installed correctly, but when I try to open it instantly closes =(
     
  10. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    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.
     
  11. leoncorrl

    leoncorrl

    Joined:
    Apr 27, 2014
    Posts:
    15
    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
     
  12. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Have you tried building with Android studio but without the stripping? (Just trying to isolate where the issue arises).
     
  13. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    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?
     
  14. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    Ok, second try :) 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.

    Bildschirmfoto 2016-09-12 um 09.26.54.png
     
  15. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    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.
     
  16. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    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.
     
    Last edited: Sep 12, 2016
  17. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,033
    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.
     
  18. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    89
    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.
     
  19. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    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.
     
  20. KnightFury_

    KnightFury_

    Joined:
    Feb 7, 2022
    Posts:
    3
    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
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I suspect that "other assets" include the executable code. IL2CPP must compile all of the managed code (which is pretty small) to much larger machine code for each architecture specified in the Player settings. You could try limiting the number of architectures that this project builds for. If that "other assets" number goes down, then that is likely the cause.