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

Question Build fails without errors

Discussion in 'Editor & General Support' started by Brady, Feb 9, 2023.

  1. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    I've upgraded my game from 2019 to 2021.3.18f1 and I cannot make a successful build. After a couple of minutes, it aborts with the following error in the log:

    "Error building Player: 4 errors"

    But there are no other errors. I've tried to scour the editor log to find any error, but it's so huge it might be easy to miss something. I've searched it though with likely terms used in an error like "exception" and of course "error", but there's nothing. No errors I can find. How can I possibly proceed?

    For what it's worth, Android is my build target.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    How to troubleshoot build failures:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

    Android build not building:

    Recently (circa July 2022) there have been reports of Unity's installer failing to install the Android Tools.

    https://forum.unity.com/threads/cant-build-for-android.1306098/

    Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022:

    https://forum.unity.com/threads/aab...y-2021-3-8-with-jdk-1-8.1322211/#post-8551193

    Android Gradle errors and other related stuff:

    https://forum.unity.com/threads/unity-gradle-bug-please-help.1368018/#post-8625789
     
    ohskaren likes this.
  3. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    Thanks, the peculiar thing about this is that it says that there were 4 errors, but none actually appear in the console. And digging through the editor log, nothing is identified as an error, so I am left to simply search for words like "unable," "exception," "could not," etc. This seems like a bug. I mean, if a fatal error occurs that prevents a build from succeeding, shouldn't whatever that error is be reported in the console?

    But I have tried building a blank project to APK and that works fine, so the toolchain is working. I'm also able to build to PC, so whatever it is, it seems like it only surfaces when Android is the build target. Also, the failure happens relatively early in the build process. After only about 2.5 minutes, in a build that normally takes about 20 to complete (assuming all assets have been processed once for that platform already).
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    As seasoned developers you and I kind of expect this. I mean... why else have an error log, right??!

    In my experience, the Android toolchain is so creaky wobbly that you simply don't get the notification in many cases.

    It's absolutely maddening, but it's great news your toolchain is good.

    The bad news is I think you're left with bisection.

    It is almost always crap like Firebase or other third party things "trying to be too clever" with their integrations and stepping on their own shoelaces.

    Good luck to you sir.
     
  5. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    I'd expect an error log to actually identify errors AS errors, rather than mixing them inconspicuously in with warnings and other messages. My log is literally 60mb. It's a huge project. I mean, if it can count how many errors there are (4 in this case), then it should report *something* about them to point me in the right direction.

    Ugh... Honestly, as a seasoned veteran of Unity, no, I absolutely do not expect this. I've been a Unity developer for 15 years, and the quality of documentation, error reporting, and just reliability in general, has taken a massive nose-dive in the last few years. The entire reason indies like myself adopted Unity and made it such a successful product in the first place was because, unlike other engines, it just worked. You could actually spend your time making your game instead of wrestling with your engine. The last 2 or 3 years, my job has increasingly become about working around stupid things in Unity that don't work the way they're supposed to, or trying to dig up information about things that should have been clearly documented. I'd say I now spend roughly half my time doing these sorts of things. This isn't what drew me to Unity all those years ago, and they're going to lose their core base the longer this continues. /rant
     
    ohskaren and Kurt-Dekker like this.
  6. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    After 3 months of agony and struggle, I believe I've finally identified the problem. Builds worked for PC but not Android, so it seemed it might be something specific to Android, obviously. However, it wound up being a shader with a _BaseMap property that was somehow defined multiple times and with a different property type. However, this shader wasn't being used anywhere in the project, and shader stripping was enabled. Further, I can't think of any reason why this shader would have been a problem when building for Android but not PC. At any rate, no error messages pointed the way to this shader. I just had to start deleting things out of the project and re-attempting a build, which needless to say, was EXTREMELY time-consuming!

    Error reporting MUST be improved. Whenever possible, all errors should identify the source of the error in as much detail as possible, not simply say unhelpfully "hey bro, an error occurred, sucks to be you, bye."
     
  7. ohskaren

    ohskaren

    Joined:
    Mar 31, 2022
    Posts:
    4
    Ah man I feel your pain, I just went through a similar process. I have also never had build issues with Unity like this until this year, and I've been using it for over 10 years now. My project had been building fine until suddenly it wasn't anymore, and I tried every possible solution on every thread I could find with no luck. Updating to a new Unity version, manually downloading and installing the JDK/SDK/NDK/Gradle, reading tons of forums, watching videos, trying every possible combination of build settings I could think of. It's enough to make you want to shoot yourself lol.

    The only thing that finally worked for me was creating a new Unity project from scratch, and one by one copying folders from Assets in the original project to the new one. Copying the whole Assets folder didn't seem to work, but manually doing the subfolders did. At each slight change I made to the project, I would attempt to make a build to make sure nothing broke it again. In the end, I lost over 3 days of work just getting back to square one.

    I agree with you, the error messages for Gradle in Unity are completely useless and that system needs to be fixed or replaced. This is a major issue and I feel concerned I won't be able to meet deadlines for clients in the future due to Gradle unexpectedly breaking everything. The errors I got in my console didn't say anything about what settings might have changed in the editor, or how to even start to address it. If there can't be a functional error system for Gradle builds, I hope that Unity will explore alternatives and get rid of it entirely.
     
    Brady and Kurt-Dekker like this.
  8. M_Dhanu

    M_Dhanu

    Joined:
    Aug 25, 2023
    Posts:
    4
    Hi
    I'm totally new to unity and trying to build an Augmented Reality application for android platform. But I keep getting the above mentioned errors when trying to build the application. I was able to build a blank app with editor version 2022.3.7f1 but can't even build a blank project with editor version 2021.3.29f1. Prefer to use 2021 version as I'm planning to use Lightship ARDK. Could you please guide me on how to correct this error
     
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
  10. valemartinezrod

    valemartinezrod

    Joined:
    Mar 3, 2022
    Posts:
    4
     
  11. M_Dhanu

    M_Dhanu

    Joined:
    Aug 25, 2023
    Posts:
    4