Cannot build for Android

Using Unity 2021.2.7 and I can’t build my project to Android. I’m also using PlayFab and Facebook SDK.
I also can’t build it on Unity 2021.1.27f1.

BuildFailedException: Incremental Player build failed!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <0cde216a590a4d6fbc3d7db7ac203c5d>:0)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <0cde216a590a4d6fbc3d7db7ac203c5d>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <374d68101b9e4829844c8329406f32cc>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <0cde216a590a4d6fbc3d7db7ac203c5d>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Building Library\Bee\artifacts\Android\d8kzr\dljh_firstpass1.o failed with output:
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(17178,50): warning: backslash and newline separated by space [-Wbackslash-newline-escape]
                // vertices[3] = CardinalToVertex(3); // [-]   \       
                                                               ^
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(17182,13): error: use of undeclared identifier 'L_6'; did you mean 'L_0'?
                NullCheck(L_6);
                          ^~~
                          L_0
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(17161,60): note: 'L_0' declared here
                Vector3U5BU5D_tFF1859CCE176131B909E2044F76443064254679C* L_0 = __this->___vertices_17;
                                                                         ^
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(17183,4): error: use of undeclared identifier 'L_6'; did you mean 'L_0'?
                (L_6)->SetAt(static_cast<il2cpp_array_size_t>(3), (Vector3_t24C512C7B96BBABAD472002D0BA2BDA40A5A80B2)L_7);
                 ^~~
                 L_0
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(17161,60): note: 'L_0' declared here
                Vector3U5BU5D_tFF1859CCE176131B909E2044F76443064254679C* L_0 = __this->___vertices_17;
                                                                         ^
In file included from E:/Games/Green Sauce Games/Hopes Farm (Free to Play)/Library/Bee/artifacts/Android/il2cppOutput/cpp/Assembly-CSharp-firstpass1.cpp:1:
In file included from C:/Unity/2021.2.7f1/Editor/Data/il2cpp/libil2cpp/pch\pch-cpp.hpp:6:
In file included from C:/Unity/2021.2.7f1/Editor/Data/il2cpp/libil2cpp\codegen/il2cpp-codegen.h:10:
In file included from C:/Unity/2021.2.7f1/Editor/Data/il2cpp/libil2cpp\codegen/il2cpp-codegen-il2cpp.h:3:
C:\Unity\2021.2.7f1\Editor\Data\il2cpp\libil2cpp\codegen\il2cpp-codegen-common-small.h(39,20): warning: implicit conversion from 'long' to 'int' changes value from -9223372036854775808 to 0 [-Wconstant-conversion]
            return INT64_MIN;
            ~~~~~~ ^~~~~~~~~
C:\Unity\2021.2.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\stdint.h(187,56): note: expanded from macro 'INT64_MIN'
#define INT64_MIN        (INT64_C(-9223372036854775807)-1)
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
E:\Games\Green Sauce Games\Hopes Farm (Free to Play)\Library\Bee\artifacts\Android\il2cppOutput\cpp\Assembly-CSharp-firstpass1.cpp(7414,10): note: in instantiation of function template specialization 'il2cpp_codegen_cast_double_to_int<int>' requested here
                return il2cpp_codegen_cast_double_to_int<int32_t>(((float)il2cpp_codegen_add(((float)il2cpp_codegen_add(((float)il2cpp_codegen_add(((float)il2cpp_codegen_add(((float)il2cpp_codegen_add(L_0, L_1)), L_2)), L_3)), L_4)), L_5)));
                       ^
2 warnings and 2 errors generated.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

I sent a bug report with my entire project. 1391435

I found the reason and I was able to fix it (by disabling this function). This code for some reason was causing the build failure. It seems some kind of bug when converting it with IL2CPP.

        void MakeVertices()
        {                                                         //        2_____1
            vertices[0] = CardinalToVertex(0); // [-]    /     \
            vertices[1] = CardinalToVertex(1); // [/]   /       \
            vertices[2] = CardinalToVertex(2); // [\]  3    #    0
            vertices[3] = CardinalToVertex(3); // [-]   \       /
            vertices[4] = CardinalToVertex(4); // [/]    \_____/
            vertices[5] = CardinalToVertex(5); // [\]    4     5
        }

It’s a simple code, it does not make sense. Here are some more functions needed by this code :

        ///<summary>Maps cardinal direction to direction hex to vertex.</summary>
        Vector3 CardinalToHex(int d)
        {
            Vector4 result;
            switch (d)
            {
                case 0: result = new Vector4(1, 0, -1); break;
                case 1: result = new Vector4(0, 1, -1); break;
                case 2: result = new Vector4(-1, 1, 0); break;
                case 3: result = new Vector4(-1, 0, 1); break;
                case 4: result = new Vector4(0, -1, 1); break;
                case 5: result = new Vector4(1, -1, 0); break;
                default: throw new ArgumentOutOfRangeException();
            }
            var hex = Grid.CubicToWorld(result) - Grid.CubicToWorld(Vector4.zero);
            return hex;
        }

Well… I sent the full project. The bug happens on all recent Unity Versions.

I am using Unity 2021.2.9f1 and I am getting the same errors trying to build to Android. I can build to Android using Mono instead of IL2CPP. If there are any updates on how to fix this, please post in this thread!

It seems that still not fixed, but a fix is coming.

Unity Issue Tracker - [IL2CPP] “BuildFailedException” and Bee errors are thrown in the Console window when building project for Android (unity3d.com)

1 Like