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

Bug Firebase for Unity causes Some Android Builds to Fail

Discussion in 'Android' started by ExNull-Tyelor, Jun 23, 2023.

  1. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    We're adding Firebase Analytics and Crashlytics to our Unity projects, and for one of the projects this seems to have worked. For another project Android fails to build 100% of the time, while iOS builds normally and the game runs in Play Mode.

    I created an empty project, changed the Project Settings to match the requirements for uploading to the Google Play Console (IL2CPP, with 64 bit binaries, App Bundle, etc.), these settings match the settings of the project that does build to Android correctly. I also changed the package name to match the one on Firebase for the project that isn't building to Android. Then I added the Firebase config files (google-services.json and GoogleService-Info.plist, the ones that Firebase gives you in the Firebase Console). So far so good, this project still builds properly to Android.

    Then I import any of the Firebase .unitypackages that you get from the Firebase Console during setup, and enable Auto Resolve. After waiting for all of that auto resolving to be done, without getting any errors, I then go to build on Android and get a build error...

    I've been working on this for nearly two days now, and nothing I've done has solved the issue, including completely nuking and redoing the changes several times, so any help would be greatly appreciated.

    It might be worth noting that the Firebase packages I'm trying to import are identical between the building project and non-building project, as is the Unity Editor version (2021.3.20f1), we're using Perforce for version control (and are setting the Version Control project settings to tell Unity this), and I'm working on an M1 MacBook.
     
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,817
    First step is to share the complete error log so that others can help out. Make sure you share the error under "Command Invocation Failure" entry if you see any in the console.
     
  3. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    I don't see anything that says "Command Invocation Failure". I see:





    An interesting point to note is that the Empty Project I created yesterday is now Building to Android properly, without any changes at all to it from yesterday to today, so there must've been something broken in the Unity/MacOS Cache causing that to fail. However the original project that started this whole ordeal is still unable to build to Android.
     
    Last edited: Jun 23, 2023
  4. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    After re-deleting and rolling back our version control, and then re-importing Firebase Analytics this project still wouldn't build to Android.

    However upon restarting the machine the project then built to Android properly. What the heck is going on here?

    Edit: Here's a bit more information. After building with Firebase Analytics properly, I then decided to import Firebase Crashlytics, and then immediately started getting the same Android build errors as before. Upon restarting my MacBook AGAIN I was then finally able to build the project to Android with both Firebase Analytics and Crashlytics.

    I still have no idea what the hell is going on here though causing the build errors in the first place. Any help would be greatly appreciated. I will also mention I opened a support portal ticket with Firebase yesterday as well, and will report back here if they give me any further information.

    Edit: I should mention that I discovered afterwards that while the projects were building after these restarts: Firebase Analytics and Crashlytics weren't actually being linked in the game, causing an exception to be thrown anytime the Firebase namespace was being accessed. I was able to solve this however, see my message below...
     
    Last edited: Jun 26, 2023
    Voxel-Busters likes this.
  5. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    For anyone who's having this issue, I was able to solve it by going to:
    Edit -> Project Settings -> Player -> (Android Tab) -> Publishing Settings
    Then making sure that the Custom Gradle Properties Template Checkbox is checked, as well as Custom Main Gradle Template Checkbox is checked.

    Afterwards I allowed the Firebase External Dependency Manager to resolve any dependencies for Android, and then Android builds would build again properly.

    I've given this information to one of the support people at Firebase, so hopefully they'll be able to update the Firebase for Unity Installation guide so that these steps are explicitly given to developers to avoid these headaches in the future.

    (The reason one project was working, even though the other wasn't, was due to the Auto Resolve Dependencies being stuck "off" even though I had actually checked the checkbox, and the dependencies being resolved in that project when I had those checkboxes checked. So later when I unchecked them it never resolved the dependencies into an unbuildable state, like the other project was in. Leading me to believe those checkboxes weren't required and didn't help the building project to build.)
     
  6. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    Bad news.

    The fix above all of a sudden stopped working, without any changes to Firebase, or the project that might cause this...

    Back to the drawing board... Again...
     
  7. ExNull-Tyelor

    ExNull-Tyelor

    Joined:
    Apr 21, 2022
    Posts:
    22
    This is so frustrating because randomly the Android builds just stop working. Android was building on Friday, and now over the holiday weekend, with literally no changes to the project from the last build on Friday to today, Android won't build again.

    This is making me look like a freaking idiot to my boss since I can't fix or even get any information on this issue and I GUARANTEE this is making him already regret his decision to let us move over to Unity from Cocos2d-x. Literally the Unity build errors as of 2021 are so cryptic that everyone thinks they have the same exact issue and no one is able to solve their damn build errors without days, weeks, or even months of debugging (see https://forum.unity.com/threads/int...r-upgrade-to-2021-1-4f1-stable.1098451/page-2).
     
  8. unity_F506661E0DE8AB889C7F

    unity_F506661E0DE8AB889C7F

    Joined:
    Dec 16, 2022
    Posts:
    1
    I have the problem exists after upgrading Unity from 2021.3.25 to 2021.3.29.

    Only when building development builds for Android platform in Batchmode.

    I was fixed this problem locally by clearing the Unity cache in the operating system (of course, I do not use the cache of previous builds from the Bee folder).

    My recommendation to you is to do that, too. The cache is located in ~/Library/Caches/com.unity3d.UnityEditor

    It is also wise to check other Unity temporary files in the ~/Library/ folder.

    Now I have a 100% successful build in Batchmode (I check via Terminal command), however the build on Jenkins is still failing, but I think I can fix that later - Jenkins needs an update.

    [18:40:29]: ▸ [35m[ ] Require frontend run. Library/Bee/Player68e5bdf6.dag couldn't be loaded[0m
    [18:40:29]: ▸ [35mStarting: /Applications/Unity/Hub/Editor/2021.3.29f1/Unity.app/Contents/Tools/netcorerun/netcorerun "/Applications/Unity/Hub/Editor/2021.3.29f1/PlaybackEngines/AndroidPlayer/AndroidPlayerBuildProgram.exe" "/Applications/Unity/Hub/Editor/2021.3.29f1/PlaybackEngines/AndroidPlayer/Bee:/Applications/Unity/Hub/Editor/2021.3.29f1/Unity.app/Contents/Tools/BuildPipeline" "Library/Bee/Player68e5bdf6.dag.json" "Library/Bee/Player68e5bdf6-inputdata.json" "Library/Bee/buildprogram0.traceevents"[0m
    [18:40:29]: ▸ [35mWorkingDir: /Users/lemel/.jenkins/workspace/idden-objects-2.0_release_1.10.1[0m
    [18:40:30]: ▸ [35mExitCode: 3 Duration: 0s475ms[0m
    [18:40:30]: ▸ [35mInternal build system error. BuildProgram exited with code 3.[0m
    [18:40:30]: ▸ [35mSystem.NullReferenceException: Object reference not set to an instance of an object.[0m
    [18:40:30]: ▸ [35mat System.SZArrayHelper.get_Count[T]()[0m
    [18:40:30]: ▸ [35mat System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)[0m
    [18:40:30]: ▸ [35mat Bee.Core.CollectionWithConditions`2.TryGetValuesFor(TConfig config, List`1& values)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.ProduceObjectFileProductionInstructions(NativeProgramConfiguration config, ArtifactLocationPolicy artifactLocationPolicy, ObjectFileProducer[] objectFileProducers, NPath[]& additionalObjectFiles, NPath[]& foundHeaders)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfigurationImpl(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfiguration(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupLibraryDependencies(NativeProgramConfiguration config, ToolChain toolchain, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfigurationImpl(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfiguration(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupLibraryDependencies(NativeProgramConfiguration config, ToolChain toolchain, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfigurationImpl(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat Bee.NativeProgramSupport.NativeProgram.SetupSpecificConfiguration(NativeProgramConfiguration config, NativeProgramFormat format, ObjectFileProducer[] objectFileProducers)[0m
    [18:40:30]: ▸ [35mat PlayerBuildProgramLibrary.PlayerBuildProgramBase.SetupIl2CppBuild() in /Users/bokken/build/output/unity/unity/Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary/PlayerBuildProgramBase.cs:line 369[0m
    [18:40:30]: ▸ [35mat PlayerBuildProgramLibrary.PlayerBuildProgramBase.SetupPlayerBuild() in /Users/bokken/build/output/unity/unity/Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary/PlayerBuildProgramBase.cs:line 171[0m
    [18:40:30]: ▸ [35mat AndroidPlayerBuildProgram.AndroidPlayerBuildProgram.SetupPlayerBuild()[0m
    [18:40:30]: ▸ [35mat PlayerBuildProgramLibrary.PlayerBuildProgramBase.RunBuildProgram() in /Users/bokken/build/output/unity/unity/Editor/IncrementalBuildPipeline/PlayerBuildProgramLibrary/PlayerBuildProgramBase.cs:line 165[0m
    [18:40:30]: ▸ [35mat PlayerBuildProgramTypeWrapper.Run(String[] args)[0m
    [18:40:30]: ▸ [35mat Program.Main(String[] args)[0m

    and
    Starting: /Applications/Unity/Hub/Editor/2021.3.29f1/Unity.app/Contents/bee_backend --profile="Library/Bee/backend_profiler1.traceevents" --stdin-canary --dagfile="Library/Bee/Player68e5bdf6.dag" --continue-on-failure --dagfilejson="Library/Bee/Player68e5bdf6.dag.json" Player
    WorkingDir: /Users/lemel/.jenkins/workspace/idden-objects-2.0_release_1.10.1
    ExitCode: 4 Duration: 31s
    Finished compiling graph: 558 nodes, 1135 flattened edges (1131 ToBuild, 6 ToUse), maximum node priority 33
    [ 1/551 0s] WriteResponseFile Library/Bee/artifacts/rsp/16389801775088756737.rsp
    [ 2/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/7x5gqmngeqka2.lump.cpp
    [ 3/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/7x5gqmngeqka3.lump.cpp
    [ 4/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/81kb4d1l90o10.lump.cpp
    [ 5/551 0s] WriteText Library/Bee/artifacts/Android/4qqi9/_dummy_for_header_discovery
    [ 6/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/wpxsexpy2l940.lump.cpp
    [ 7/551 0s] WriteText Library/Bee/artifacts/Android/ihupg/_dummy_for_header_discovery
    [ 8/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/3x587gwxbi980.lump.cpp
    [ 9/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/iuqkd4lbop681.lump.cpp
    [ 10/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ftg7txuhutow1.lump.cpp
    [ 11/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/7x5gqmngeqka4.lump.cpp
    [ 12/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ftg7txuhutow2.lump.cpp
    [ 13/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ftg7txuhutow0.lump.cpp
    [ 14/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ztsofiijv9fc1.lump.cpp
    [ 15/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ztsofiijv9fc2.lump.cpp
    [ 16/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ztsofiijv9fc0.lump.cpp
    [ 17/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ztsofiijv9fc3.lump.cpp
    [ 18/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/iuqkd4lbop680.lump.cpp
    [ 19/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/ztsofiijv9fc4.lump.cpp
    [ 20/551 0s] MakeLump Library/Bee/artifacts/Android/x6ly2/49duclu1ktoa0.lump.cpp
    ..........
     
    Last edited: Jul 28, 2023