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

Unity stuck when building IL2CPP for Android game

Discussion in 'Editor & General Support' started by marwinwend, Jun 25, 2021.

  1. marwinwend

    marwinwend

    Joined:
    Apr 4, 2018
    Posts:
    7
    Almost every time when I try to build my android app unity gets stuck at "Building native binary with IL2CPP".

    The timer on the little window keeps counting forever. So just waiting is no option. I have to restart my pc and try again about five times to fix it. So every time I want to build my app it takes ages and this frustrates me.

    I also made this screenshot of unity in my taskmanager where you can see there are just 4 subtasks running(bellow 0.5% of cpu capacity). Normally there should be running about 15-20 tasks but after every restart of my system another number of tasks are running. The red text means "no respond".
    Things I did to try fixing the error:
    1. Reinstall all unity versions
    2. Reinstall unity hub
    3. Reinstall Windows 10
    4. Moving the folder of the project to another drive
    5. Reinstall android sdk
    6. Actually reinstall everything
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    Can you build an empty app with one scene? If so, then start removing chunks of your app until it builds, and whatever last chunk you removed might contain clues to what is going wrong.

    (This presupposes you are using source control and ripping stuff out of your project is trivial to restore!)

    ALSO: sometimes lightmap baking can take a ridiculous amount of time. I have seen lightmap baking take several hours to complete, and at first I thought the build had crashed. But if you are only seeing this when IL2CPP is in effect and not when Mono is in effect, it's probably not lightmaps.
     
  3. marwinwend

    marwinwend

    Joined:
    Apr 4, 2018
    Posts:
    7
    Thanks for the tip I will try it out. I have a big project so it will take some time. The building always get stuck in building IL2CPP, so it don't occur probably because of baking lightmaps.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    I'm not always convinced that the progress bar accurately tells you what it is actually doing. :)
     
  5. marwinwend

    marwinwend

    Joined:
    Apr 4, 2018
    Posts:
    7
    Sure, but I already waited 6 hours for one time and it didn't finish the build
     
  6. Janette5

    Janette5

    Joined:
    Dec 14, 2020
    Posts:
    15
    That part - building native library - took 10.5 hours to build a game on my PC. It seems to be stuck - but I left it overnight and it did complete the build. It might be that you just have to wait longer.
     
  7. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    Something has gone very wrong to take this long. Candidates to check include a really aggressive antivirus program just clogging up the works, or else perhaps just a VASTLY underpowered system, perhaps with insufficient RAM so that the OS is constantly paging work to disk and back, which might be compounded by a slow disk.
     
  8. Janette5

    Janette5

    Joined:
    Dec 14, 2020
    Posts:
    15
    I don't think my PC is vastly underpowered - it's still pretty much as good as I'm going to get locally - without paying a fortune for a custom build or a custom import. But it might be underpowered compared to what is available in Europe / North America.

    Processor Intel(R) Core(TM) i5-3470T CPU @ 2.90GHz
    Installed RAM 8.00 GB

    I do have the hard drive "fast" read / write setting disabled - because if the power goes down while it's reading / writing it creates a bad sector on the hard drive - and the power where I live - goes down. I've already had to replace a hard drive because it had too many bad sectors. That would be the only known culprit - but unless I buy some kind of power bank for my PC, I can't risk changing that.

    Unity in general is painfully slow to install, to open a file for the first time, to open Visual Studio for the first time and ridiculously slow with the 64 bit build. The 32 build in contrast takes about 5 minutes for the first build of an .apk and a few minutes thereafter.

    I do have an anti-virus but I excluded the directories - Unity, Visual Studio, the game and turned it onto silent mode.

    The real joke - on my cell phone which is 64 bit, building a 32 bit game (5 minutes) vs building a 64 bit game (10.5 hours) there was zero difference in game-play or performance in my particular game.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    For those seeing this issue I have two questions:

    Is BitDefender anti-virus running on your computer? We've recently discovered some bad interactions with it and IL2CPP.

    Are there any more details in the editor log file that might indicate an error has occurred?
     
  10. Janette5

    Janette5

    Joined:
    Dec 14, 2020
    Posts:
    15
    No, I'm running Norton 360.
    I had no errors that I recall, the build - .apk - was successful, it just took long.
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Ok, then this is a different problem from the one we see with Bit Defender.

    Have a look in the Temp/ directory for the generated IL2CPP source code after the build completes. There should be a file named profile.json there - this is a Chrome Tracing file that will indicate what caused the build to take so long. I can analyze it if you can send it to me.
     
  12. Janette5

    Janette5

    Joined:
    Dec 14, 2020
    Posts:
    15
    I ran a build on IL2CPP on the same app that previously took 10.5 hours to get you the .json file - but it took less than 30 minutes this time - running it on 2021.1.6.

    I can't remember on what I ran it previously - but it was a while back, so there would've been a few Unity, Windows and Antivirus updates between then and now.
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Ok, 30 minutes is much better than 10.5 hours. I wonder what was happening before though?
     
  14. Janette5

    Janette5

    Joined:
    Dec 14, 2020
    Posts:
    15
    I don't know - because like the original poster - I was stopping it and trying again a few times over a couple of days because it was taking so long - it wasn't a once-off. Also it was using the resources to the point that if I even moved my mouse during the process, my PC would hang irrecoverably.

    Things I changed -
    1. I might not have excluded the directory in which it was building the game from Norton. I was previously only excluding the relevant sub-folders but changed that to exclude the top directory that has all my created games folders in it. (However, the 32-bit build never took longer than 5 minutes.)
    2. I stopped the build, because it took so long by end-tasking Unity in the task manager. It might have left remnants of the build on the PC which meant that it was interfering with subsequent builds. Now that it is weeks later, Norton Utilities or Windows Updates will have removed those remnants.
    3. I had started a clean company in 2021 and imported the game again as a custom asset package - so that clean build might also have contributed to it. Once I tested the game in 2021 and it worked - I deleted the old data, so can't re-test that. (I just don't remember if the previous attempt was on 2020 LTS - or if it was on the 2021 version - but I think it might've been on 2020 LTS).
    I haven't changed anything to my pc and I typically don't change the settings - it uses the Windows default settings - same with Norton.
     
  15. marwinwend

    marwinwend

    Joined:
    Apr 4, 2018
    Posts:
    7
    Yes I have Bitdefender on my system. Do you have a solution for my situation?
     
  16. akshith_s

    akshith_s

    Joined:
    Apr 26, 2021
    Posts:
    3
    Hi JoshPeterson

    Even I facing similar issue with Bitdefender, any Updates ?..
     
  17. vila4480

    vila4480

    Joined:
    Sep 18, 2019
    Posts:
    7
    Same issue... uninstalling Bitdefender just in case... any ideas on how to fix this would be appreciated.
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Please let me know if removing BitDefender helps with this issue. At this point we are not sure why the interaction with BitDefender is such as problem - it is not something we have reproduced internally yet. So I can't offer more details, unforttunately.
     
  19. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    659
  20. vila4480

    vila4480

    Joined:
    Sep 18, 2019
    Posts:
    7
    @JoshPeterson
    TLDR: got it working - I think it was the project folder path that was too long.

    One thing I noticed was that when I removed BitDefender Windows Defender kicked in and I started getting all sorts of security notifications when building my project (all related to il2cpp, bee.exe, etc.). BitDefender was probably doing the same, just not telling the user about it.

    I went ahead and went to Window's Virus & Threat Protection panel -> Protection History and allowed each file to operate freely. After that, I also tried setting all files, including Unity to run as admin and removed the Read Only status from the folders (under folder properties).

    However, what I think actually worked was none of this - but rather moving the project folder to the root of my disk, thus shortening the path length to the project's build folder. I tried building at each step and it only started working when I finally moved the folder.

    I'm working with WebGL and I'm having trouble updating the scripts (magically getting old script debugs in the Javascript debugger). I'm guessing it's unrelated? I have no clue how to solve this, but if I find out it's somehow related I'll post it here.

    Thanks for all your support guys!
    Keep the bugs at bay!
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Thanks for the details - this does seem to be unrelated.