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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

il2cpp "File too large" error. Cannot build for Android using il2cpp

Discussion in 'Android' started by MasterStrike88, Sep 7, 2022.

  1. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    Hello, first time poster here.

    I have searched using google, and through this forum's search engine and I cannot find the solution to my problem.

    I am trying to build using the recommended Android SDK modules (provided by Unity hub installer), and I have upgraded them to the latest versions.

    As I am building, Unity throws these errors and the build fails:

    Building Library\Bee\artifacts\Android\iz17e\libil2cpp.so failed with output:
    C:/Program Files/Unity/Hub/Editor/2021.3.8f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin\ld.gold.exe: fatal error: Library/Bee/artifacts/Android/iz17e/libil2cpp.so: File too large
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    UnityEditor.GenericMenu:CatchMenu (object,string[],int)


    The culprit seems to be the libil2cpp.so which says "File too large". I am using the default AR Core template, no changes made.

    I have uninstalled the Android modules, reinstalled them and ensured windows 10 SDK and Visual Studio 2019 are all up to date. I'd appreciate any help I can get, as I'm supposed to use this for a school project and neither I or any of my peers/teachers can figure out what's causing it.

    Cheers
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,788
    Do you happen to have script debugging enabled? If so, you may want to disable that, as it will make the output executable much larger.

    Another option is to use Unity 2022.2 instead. That version uses a newer Android NDK (r23) with the lld linker. That linker handles large files much better than the gold linker used in Unity 2021.
     
  3. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    Hi Josh, and thank you for your quick response.

    As far as I can tell, script debugging is disabled : upload_2022-9-7_13-10-14.png

    Apparently, I only have access to version 2021.3.8f1 through my student license. However, my 14 other classmates have not encountered this issue.

    After sending them my project folder (still just the default AR Core template), they can build it just fine.

    Is there an alternative to upgrading to 2022 here? Can I reinstall the il2cpp or a different version android kit somehow? Can I alter the maximum permissable filesize in some config? I'm running a medium/high end system with 32gb ram and loads of GB space for temporary file storage. My classmates running medium-spec laptops are not encountering this issue.

    I assume reinstalling Unity won't have an effect, as the linker is part of the Android SDK module?

    Thanks in advance.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,788
    You could also try changing the IL2CPP Code Generation option in the Build Settings to a value of "Faster (smaller) builds". That will change the IL2CPP code generation to optimize for code size.

    I don't find it odd that this works for other though. The error message looks like it is a bug in the linker from the Android NDK. I'm unclear why the linker would fail for you but work for others with the same inputs.
     
  5. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    Just tried to change for Faster (smaller) builds, and it's throwing the same error as before. I've essentially sat side-by-side with a classmate who this works for, and compared settings across the board. I just can't get it to build. It builds just fine in "mono" scripting backend, but not with the il2cpp option.

    Before reinstalling the Android SDK modules, I tried copying the "Android Player" folder in PlaybackEngines from a classmate, but that didn't work either.

    I'm really at a loss here.
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,788
    I'm not sure what is happening as well. Can you ensure that both computers have the same Android NDK version installed?
     
  7. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    We are both on r21d according to the CHANGELOG.md
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,788
    I'm not sure what the cause is then, sorry!
     
  9. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    That's a shame.

    I've spent the past 6 hours troubleshooting, trying a different version. Reinstalled Unity, all the modules. Yet I end up with the exact same problem.

    Which dependencies do il2cpp rely on? Is there something I'm missing? I thought it would be an "out of the box" solution by simply adding them in the modules settings. Could there be firewall settings blocking il2cpp? I can't for the life of me figure out what's wrong.

    Is there anything of value in the remaining error messages, or are these simply "nested" messages from the build process?

    upload_2022-9-7_21-29-45.png

    There must be something I can do to override the File size limit problem?

    After all, it's simply the AR Core template - basically the bare bones of an AR solution.
     
  10. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    I got my hands on the 2022.2 version, and it builds using il2cpp.

    I'm still puzzled as to why it would not work in version 2021.3.8f1 and 2021.3.9f1
     
  11. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,679
    Could you attach Editor.log?

    Like Josh said, the issue is with ld.gold.exe which comes from Android NDK, thus it's hard to say what's wrong.

    You can try using unofficial workaround:
    * Set UNITY_IL2CPP_ANDROID_USE_LLD_LINKER env variable to 1
    * Close Unity
    * Delete Library folder of your project
    * Reopen project and try building again

    This will force Unity to use lld linker, which should be better at handling errors like that.

    Note: This is not needed in 2022.2, because lld is always used there.
     
  12. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    Attached the Editor.log (Forum forbids .log file extension, so it's a .txt)

    I'll try the workaround.
     

    Attached Files:

  13. MasterStrike88

    MasterStrike88

    Joined:
    Sep 2, 2022
    Posts:
    8
    Brief update:

    I changed my System variable upload_2022-9-8_21-10-19.png

    , closed Unity, removed the Library folder and rebuilt the project.

    Still get the same error message.

    Please verify I'm supposed to set the env variable in the Windows advanced settings?
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,788
    That seems like the right way to use the environment variable. Does the error message still indicate that the gold linker is used? This environment variable should change the behavior to use the lld linker.
     
  15. strompyvipex

    strompyvipex

    Joined:
    Aug 18, 2021
    Posts:
    2


    Und Now ??? Does it work?
     
  16. strompyvipex

    strompyvipex

    Joined:
    Aug 18, 2021
    Posts:
    2


    je have the same problem, yesterday I could build my game without any problem, but today it dont work and I dont know why