AAB build fails when moving project to a different directory

My project is located in the default project directory

C:\Users\adnan\Documents\Unreal Projects\MyGame

I have AAB packaging enabled, and I build the game (by clicking “Launch” inside the editor), everything works, the game launches and the AAB is generated inside the build directory.

I copy & paste the same project to another dir:

C:\Users\adnan\Documents\Unreal Projects\MyGame2

And do the same, build fails. Same issue happens when I build using CLI and from a “clean” project (no intermediate directory etc)


What I think went wrong:

Based on the error in the log below, the issue is that the gradle directory isn’t generated inside Intermediate\Android\gradle (this directory is empty)

In both attempts I’m using the same UE4 installation and configuration, and the same android build tools (NDK and SDK).


When it doesn’t work, I get this error in the build log:

Creating rungradle.bat to work around commandline length limit (using unused drive letter V:)
  Writing symbols to C:\Users\adnan\Documents\Unreal Projects\build\Binaries/Android\OrcsAndHumans_Symbols_v3/OrcsAndHumans-arm64\libUE4.so
  Fixing minSdkVersion; requires minSdkVersion of 21 for App Bundle support
  Fixing minSdkVersion; requires minSdkVersion of 21 for App Bundle support
  ERROR: Unhandled exception: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\adnan\Documents\Unreal Projects\build\Intermediate\Android\gradle\app\abi.gradle'.
            at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
            at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
            at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
            at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
            at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
            at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
            at UnrealBuildTool.UEDeployAndroid.MakeApk(AndroidToolChain ToolChain, String ProjectName, TargetType InTargetType, String ProjectDirectory, String OutputPath, String EngineDirectory, Boolean bForDistribution, String CookFlavor, UnrealTargetConfiguration Configuration, Boolean bMakeSeparateApks, Boolean bIncrementalPackage, Boolean bDisallowPackagingDataInApk, Boolean bDisallowExternalFilesDir, Boolean bSkipGradleBuild) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 4143
            at UnrealBuildTool.UEDeployAndroid.PrepTargetForDeployment(TargetReceipt Receipt) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Android\UEDeployAndroid.cs:line 4347
            at UnrealBuildTool.BuildMode.Build(List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, ISourceFileWorkingSet WorkingSet, BuildOptions Options, FileReference WriteOutdatedActionsFile) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 384
            at UnrealBuildTool.BuildMode.Execute(CommandLineArguments Arguments) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 219
            at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\Build\++UE4+Licensee\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 550
Took 28.2069995s to run UnrealBuildTool.exe, ExitCode=6
UnrealBuildTool failed. See log for more details. (C:\Users\adnan\AppData\Roaming\Unreal Engine\AutomationTool\Logs\C+UE_4.25\UBT-OrcsAndHumans-Android-Shipping.txt)

I solved it myself through trial and error.

The build fails if the project directory doesn’t have the same name as the project.

So “MyProject” needs to be inside a directory that’s called “MyProject” (so MyProject/MyProject.uproject) for AAB builds to work.

Pretty dumb, but probably a bug on UE side.

1 Like

Just check that you haven’t “build” word in package path.

And you have :wink:

2 Likes

OMFG - I’ve wasted 2 days of my life, and this post probably saved me yet a few more days; THANK YOU. Building locally was fine, building on a build machine named builder (hence workspace in /home/builder/...) was failing as mentioned in the OP’s post.

Whoever wrote logic based on substring match inside a full path against build should be shot. Wackiness on their part assuming that artifacts won’t be living in a path with the word build in it. me facepalms

Still an issue in 5.0.3. Thank you for this.

This is not a bug on the engine side, this is bug on your project side.

to fix this bug: everytime update the directors in your config files according to the directory you moved the project in.
by default every project has directors of the directory in which it was created using unreal engine.
the directors are not only in config files, sometimes they operates form the catch, and if the catch is not updated by the engine this is a bug but in your case your by your hand moved the project to another directory which is moved with the old directors and you need to update them. Engine has nothing to do with them.

hope it helps
cheers!

1 Like

Using Gitlab CI/CD Runner creates a default sub-directory called ‘build’ which encountered the subject error but thankfully brought me to this solution and lead to having to override the default behavior and use a custom folder path. I would state that if it breaks down a major part of functionality (namely packaging a product for deployment) without a guided solution (e.g. a catch that states you should rename the folder/subfolder) I would call that a pretty significant bug.

2 Likes

Thanks, ufna.

In my case, build was not the issue but Workname.Contains("/.") since my Jenkins home directory was $HOME/.jenkins:wink: