Cooking from Command Line Android

Hi

I was looking into to minimize package size for mobile.

I saw on

that there is an option -compressed when cooking from commandline. Is this compressed option automatically used from the editor when building the package for shipping?

Unfortunately I am also unsure about how to cook for Android from command line, when I only want to use ETC1 for example. No matter what I try the build get stuck at GC and no folder is “Sandboxes” folder is created like it is mentioned for the output directory.

Sounds like you are doing cook on the fly, not just precooking (although I didn’t see that on that page). The GC line is normal for using cook on the fly, because the cooker starts up and then waits for a client (after collecting some garbage, aka GC).

You would want to do:

UE4Editor -run=cook -targetplatform=Android_ETC1 -map=Map1+Map2 -compressed

And the output is now in Saved/Cooked, not Sandboxes (we had to shorten some paths recently).

Josh

Thanks, but still not working. Just to mention, the project packages fine from within the editor:

Here’s what I do:

  • In a dos window I go to the directory of my Engine in Engine/Binaries/Win64
  • UE4Editor -project=“Directory of my game including uproject file” -run=cook -targetplatform=Android_ETC1 -map=AllMaps -Compressed

Then a window pops up and goes trough a process very fast in 10s and closes automatically. So I dont see whats the error there. I tried to make a batch file with a PAUSE command to prevent automatic closing of the window, but as it opens a new dos window I cannot prevent it from closing I think.

No Etc Cooked Folder is created anywhere.

Edit: If the -compress option doesn’t do anything different than the In-Editor shipping conifugration, then I won’t bother with this problem anymore.

Ah, sorry, use UE4Editor-cmd, which is the command prompt printing version. That will help figure it out.

It markes the build as a success with 9.36s, but I can’t find any apk or obb anywhere.

Also I have to use -maps instead of -maps, otherwise it wont find the packages for the levels.

The only warning which I think is relevant is:

LogDirectoryWatcher:Warning: Failed to begin reading directory changes for C:/Users/username/AppData/Local/UnrealEngine/4.5/Binaries/Win64. Error: 0

[2015.02.03-23.49.47:665][ 0]LogInit:Display: Success - 0 error(s), 26 warning(s)

(The other warnings are deleted fonts)

I have both my project and the unreal engine installed on a second hard drive. Don’t know if that is relevant here.

On my main hard drive under appdate/local a Android_ETC1 Folder is created after the build which only contains a Engine folder with a AssetRegistry.bin.

Again I am running the command from within my engine folder on the 2nd hard drive under Binaries\Win64, which I assume is correct.

I also ran cmd as administrator.

You are only cooking, not packaging. You need to use UAT to do a package.

Engine\Build\BatchFIles\RunUAT BuildCookRun -project=MyProject/MyProject.uproject -skipcook -stage -package -pak -archive -archivedir=

Note that you already cooked, so I specified to skip cook, but if you want to cook and package at once, you would use -cook -AdditionalCookerOptions="-compressed"

(Note I haven’t tested the AdditionalCookerOptions in awhile, but this should work)

Josh

Ok so building is the same as cooking. Hope I got that right :slight_smile:

I was just wondering about this compresse option, because always when uploading on google play it gives me the message that apk and obb could be more compressed.

When using both of the packaging commands I get the error below about a missing automation script. This is on 4.51, but I checked on 4.7, which also doesn’t have the script in the specified folder.

ScriptCompiler.LoadPreCompiledScriptAssemblies: ERROR: Scripts folder F:\UE4\Epic Games\4.5\Engine\Binaries\DotNET\AutomationScripts does not exist!
Program.Main: ERROR: AutomationTool terminated with exception:
Program.Main: ERROR: Exception in AutomationTool: AutomationScripts.Automation.dll was not found or could not be loaded, can’t run scripts.
Stacktrace: at AutomationTool.ScriptCompiler.LoadPreCompiledScriptAssemblies(List1 OutScriptAssemblies) at AutomationTool.ScriptCompiler.FindAndCompileAllScripts(List1 AdditionalScriptsFolders)
at AutomationTool.Automation.Process(String[] CommandLine)
at AutomationTool.Program.MainProc(Object Param)
at AutomationTool.InternalUtils.RunSingleInstance(MainProc Main, Object Param)
at AutomationTool.Program.Main()
Program.Main: ERROR: AutomationScripts.Automation.dll was not found or could not be loaded, can’t run scripts.
ProcessManager.KillAll: Trying to kill 0 spawned processes.

It might be nice to use packaging from command line, because then it would be maybe possible to delete some engine content which I am unable to delete at runtime. (To minimize apk/obb size)

dont forget the platform=Android

UnrealBuildTool: ERROR: GetBuildPlatform: No BuildPlatform found for Android

Hi, I know it’s a bit late to write here, but I’m trying to do this myself. Achievement compile a. apk but when I open it in the device it asks for obb file, I do not know if I should specify that it must be created or created all packaged inside the apk.
the command you use is the following …

RunUAT BuildCookRun -project="D:\my.uproject" -noP4 -platform=Android -clientconfig=Shipping -cook -allmaps -build -stage -pak -archive -archivedirectory="D:\Users\hh\Documents\Builds"

I do not know what I did wrong, thank you very much for the help.