I have been trying to build a custom build pipeline for my project. I created an editor window with a build button that calls UnityEditor’s BuildPipeline.BuildPlayer method to make a build targeting android platform.
Unity Version: 2022.3.14f1
Here’s my build code:
public static string[] GetFirstScene() {
string[] scenes = new string[1];
for(int i = 0; i < scenes.Length; i++) {
scenes[i] = EditorBuildSettings.scenes[i].path;
}
return scenes;
}
public static void BuildAndroid(string apk_name, string app_version, int bundle_version_code, bool is_prod = false) {
PlayerSettings.Android.keystoreName = "myproject.keystore";
PlayerSettings.Android.keystorePass = "password";
PlayerSettings.Android.keyaliasName = "alias";
PlayerSettings.Android.keyaliasPass = "password";
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7 | AndroidArchitecture.ARM64;
PlayerSettings.Android.bundleVersionCode = bundle_version_code;
PlayerSettings.bundleVersion = app_version;
string extension = is_prod ? "aab" : "apk";
if(!Directory.Exists("../xbuilds/"))
Directory.CreateDirectory("../xbuilds/");
if(!Directory.Exists($"../xbuilds/{apk_name}/"))
Directory.CreateDirectory($"../xbuilds/{apk_name}/");
BuildPipeline.BuildPlayer(GetFirstScene(), $"../xbuilds/{apk_name}/{apk_name}.{extension}", BuildTarget.Android, BuildOptions.None);
}
Here’s the issue: Whenever I run my tool, editor crashes. Weirdly the build process is fine when I access the usual build flow of going under “File-> Build Settings-> Build”.
Here’s the crash log:
Crash Log
Assertion failed on expression: ‘!(copyData == NULL && byteSize != 0)’
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEditor.BuildPipeline:BuildPlayerInternal (string[ ],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[ ])
UnityEditor.BuildPipeline:BuildPlayer (string[ ],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[ ])
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
UnityEditor.BuildPipeline:BuildPlayer (string[ ],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid (string,string,int,bool) (at Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs:62)
HWBuildPipeline.BP_BuildTool:BuildAndroid () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:106)
HWBuildPipeline.BP_BuildTool:smile:rawAndroidOptions () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:92)
HWBuildPipeline.BP_BuildTool:OnGUI () (at Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:39)
UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect)
UnityEditor.DockArea:smile:rawView (UnityEngine.Rect)
UnityEditor.DockArea:OldOnGUI ()
UnityEngine.UIElements.IMGUIContainer:smile:oOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,System.Action,bool)
UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,bool)
UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase,bool,bool)
UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI (UnityEngine.UIElements.EventBase,bool,bool)
UnityEngine.UIElements.IMGUIContainer:ProcessEvent (UnityEngine.UIElements.EventBase)
UnityEngine.UIElements.CallbackEventHandler:HandleEvent (UnityEngine.UIElements.EventBase)
UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase)
UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy:smile:ispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool)
UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
UnityEngine.UIElements.EventDispatcher:ProcessEventQueue ()
UnityEngine.UIElements.EventDispatcher:OpenGate ()
UnityEngine.UIElements.EventDispatcherGate:smile:ispose ()
UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
UnityEngine.UIElements.EventDispatcher:smile:ispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
UnityEngine.UIElements.UIElementsUtility:smile:oDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
[Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs line 62]
=================================================================
Native Crash Reporting
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Managed Stacktrace:
at <0xffffffff>
at UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck <0x001a7>
at UnityEditor.BuildPipeline:BuildPlayerInternal <0x003ca>
at UnityEditor.BuildPipeline:BuildPlayer <0x00a4a>
at UnityEditor.BuildPipeline:BuildPlayer <0x001fa>
at UnityEditor.BuildPipeline:BuildPlayer <0x00462>
at HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid <0x00642>
at HWBuildPipeline.BP_BuildTool:BuildAndroid <0x00232>
at HWBuildPipeline.BP_BuildTool:smile:rawAndroidOptions <0x00682>
at HWBuildPipeline.BP_BuildTool:OnGUI <0x0015a>
at UnityEditor.HostView:InvokeOnGUI <0x00459>
at UnityEditor.DockArea:smile:rawView <0x000d2>
at UnityEditor.DockArea:OldOnGUI <0x0156a>
at UnityEngine.UIElements.IMGUIContainer:smile:oOnGUI <0x01dc8>
at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x00b92>
at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x0024a>
at UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent <0x000e2>
at UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw <0x0029a>
at UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI <0x00f72>
at UnityEngine.UIElements.IMGUIContainer:ProcessEvent <0x000f2>
at UnityEngine.UIElements.CallbackEventHandler:HandleEvent <0x00a92>
at UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase <0x0008b>
at UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase <0x0016a>
at UnityEngine.UIElements.MouseCaptureDispatchingStrategy:smile:ispatchEvent <0x01212>
at UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies <0x002b5>
at UnityEngine.UIElements.EventDispatcher:ProcessEvent <0x0046a>
at UnityEngine.UIElements.EventDispatcher:ProcessEventQueue <0x0033a>
at UnityEngine.UIElements.EventDispatcher:OpenGate <0x001ea>
at UnityEngine.UIElements.EventDispatcherGate:smile:ispose <0x0008a>
at UnityEngine.UIElements.EventDispatcher:ProcessEvent <0x01442>
at UnityEngine.UIElements.EventDispatcher:smile:ispatch <0x0043a>
at UnityEngine.UIElements.BaseVisualElementPanel:SendEvent <0x0017a>
at UnityEngine.UIElements.UIElementsUtility:smile:oDispatch <0x00c62>
at UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent <0x002c2>
at UnityEngine.UIElements.UIEventRegistration:ProcessEvent <0x00233>
at <>c:<.cctor>b__1_2 <0x0009a>
at UnityEngine.GUIUtility:ProcessEvent <0x002e0>
at :runtime_invoke_void_int_intptr_intptr& <0x001b5>
Received signal SIGSEGV
Obtained 71 stack frames
0x00007ff63c2be3f2 (Unity) CachedWriter::Write
0x00007ff63c69e161 (Unity) StreamedBinaryWrite::TransferTypelessData
0x00007ff63c0abcad (Unity) Texture2D::Transfer
0x00007ff63c688a43 (Unity) SerializedFile::WriteObject
0x00007ff63c6723de (Unity) PersistentManager::WriteFile
0x00007ff63c67443f (Unity) PersistentManager::WriteFile
0x00007ff63d3864b1 (Unity) WriteSharedAssetFile
0x00007ff63d37302e (Unity) CompileSharedAssetsFile
0x00007ff63e0c6881 (Unity) BuildPlayerData
0x00007ff63e0d0937 (Unity) DoBuildPlayer_Build
0x00007ff63e0cf346 (Unity) DoBuildPlayer
0x00007ff63e0c2638 (Unity) BuildPlayer
0x00007ff63be3ce9f (Unity) BuildPipeline::BuildPlayerInternalNoCheck
0x00007ff63bb6c1cc (Unity) BuildPipeline_CUSTOM_BuildPlayerInternalNoCheck
0x000002dc4e2b5c08 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck (string[ ],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[ ],bool)
0x000002dc4e2b404b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayerInternal (string[ ],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[ ])
0x000002dc4e2b2e0b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (string[ ],string,string,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,UnityEditor.BuildOptions,string[ ])
0x000002dc4e2b1b8b (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
0x000002dc4e2b1173 (Mono JIT Code) UnityEditor.BuildPipeline:BuildPlayer (string[ ],string,UnityEditor.BuildTarget,UnityEditor.BuildOptions)
0x000002dc4e2af4a3 (Mono JIT Code) HWBuildPipeline.BP_BuildAndroid_ES:BuildAndroid (string,string,int,bool) (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/BP_BuildAndroid_ES.cs:62)
0x000002dc4e2aeca3 (Mono JIT Code) HWBuildPipeline.BP_BuildTool:BuildAndroid () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:106)
0x000002dc4e2acf43 (Mono JIT Code) HWBuildPipeline.BP_BuildTool:smile:rawAndroidOptions () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:92)
0x000002dc4e2a393b (Mono JIT Code) HWBuildPipeline.BP_BuildTool:OnGUI () (at D:/UnityProjects/HitwicketSuperstars/HitwicketUnity2/Assets/Editor/BuildPipeline/Tool/BP_BuildTool.cs:39)
0x000002dc570adbba (Mono JIT Code) UnityEditor.HostView:InvokeOnGUI (UnityEngine.Rect)
0x000002dc570ad643 (Mono JIT Code) UnityEditor.DockArea:smile:rawView (UnityEngine.Rect)
0x000002dc5708c4db (Mono JIT Code) UnityEditor.DockArea:OldOnGUI ()
0x000002dc55e777c9 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:smile:oOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool)
0x000002dabab00b93 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool)
0x000002dc52f0729b (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,System.Action,bool)
0x000002dc52f06f73 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,bool)
0x000002dc52f061ab (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase,bool,bool)
0x000002dc52f05e03 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI (UnityEngine.UIElements.EventBase,bool,bool)
0x000002dc50ba4663 (Mono JIT Code) UnityEngine.UIElements.IMGUIContainer:ProcessEvent (UnityEngine.UIElements.EventBase)
0x000002dc50ba36c3 (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEvent (UnityEngine.UIElements.EventBase)
0x000002dc50ba2b6c (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase)
0x000002dc50ba205b (Mono JIT Code) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase)
0x000002dc52efe313 (Mono JIT Code) UnityEngine.UIElements.MouseCaptureDispatchingStrategy:smile:ispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
0x000002dc50cfd236 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool)
0x000002dc50cfbacb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
0x000002dc50b6c0eb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEventQueue ()
0x000002dc50b6bceb (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:OpenGate ()
0x000002dc50b6ba6b (Mono JIT Code) UnityEngine.UIElements.EventDispatcherGate:smile:ispose ()
0x000002dc50cfcaa3 (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel)
0x000002dc50cfaa7b (Mono JIT Code) UnityEngine.UIElements.EventDispatcher:smile:ispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode)
0x000002dc50cfa58b (Mono JIT Code) UnityEngine.UIElements.BaseVisualElementPanel:SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode)
0x000002dc5370cf13 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:smile:oDispatch (UnityEngine.UIElements.BaseVisualElementPanel)
0x000002dc5370c153 (Mono JIT Code) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&)
0x000002dc5370bac4 (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr)
0x000002dc5370b7bb (Mono JIT Code) UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr)
0x000002dc5370a081 (Mono JIT Code) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
0x000002dc5370a346 (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr)
0x00007ff8ed4d4c1e (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ff8ed40d254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ff8ed40d3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff63c5d0ad4 (Unity) scripting_method_invoke
0x00007ff63c5ae844 (Unity) ScriptingInvocation::Invoke
0x00007ff63c5a9455 (Unity) ScriptingInvocation::Invoke
0x00007ff63c70224a (Unity) Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent
0x00007ff63d1004f8 (Unity) GUIView::ProcessRetainedMode
0x00007ff63d6d00a0 (Unity) GUIView::OnInputEvent
0x00007ff63d100443 (Unity) GUIView::ProcessInputEventFromAPI
0x00007ff63d100318 (Unity) GUIView::ProcessInputEvent
0x00007ff63d6d0ede (Unity) GUIView::ProcessEventMessages
0x00007ff63d6cacf4 (Unity) GUIView::GUIViewWndProc
0x00007ff9455aef75 (USER32) CallWindowProcW
0x00007ff9455ae69d (USER32) DispatchMessageW
0x00007ff63d6a4643 (Unity) MainMessageLoop
0x00007ff63d6a9690 (Unity) WinMain
0x00007ff63ea8c26e (Unity) __scrt_common_main_seh
0x00007ff944b47344 (KERNEL32) BaseThreadInitThunk
0x00007ff946a226b1 (ntdll) RtlUserThreadStart
Solutions that I have already tried are:
- Reimporting all the assets
- Upgrading unity to latest LTS (from 2022.3.14f1 → 2022.3.25f1)
- Deleted Library & Temp folders from the project