I have this weird behavior in Unity 2022.3.4f1 My project does not have any compile error or so, and builds fine. However, after I build my app 2-3 times, it just says that my build is failed without giving me any clue as to what’s happening.
I found a workaround, right-click on the Assets folder in the Project window and Reimport All Assets.
Then it again builds okay for 2-3 times until it starts to fail again.
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.
Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33…):
Is there a way to update my editor version? Or do I have to download the latest version?
I looked in the editor, it seems like it is installing the new version instead of updating the present one
This build error happens only when I use IL2CPP, if I switch to Mono it is building fine.
I thought maybe indeed it has something to do with the IL2CPP Cache, but I couldn’t find the folder inside the Library/
Indeed it’s only happening with IL2CPP… Literally to make a second build i need to remove all IL2CPP and BEE folder from Library. It’s the same for me the first build is fine. Second always fail.
I did clean build no effect at all until I don’t delete everything manually.
For example now i have building errors if i do clean build it will do nothing if i start delete everything manually it build successfully so i need to do this every time that i need a second build