Here is my build script from command line
private static string[] GetEnabledScenes()
{
return (
from scene in EditorBuildSettings.scenes
where scene.enabled
where !string.IsNullOrEmpty(scene.path)
select scene.path
).ToArray();
}
private static void PerformBuild()
{
var buildTarget = BuildTarget.Android;
Console.WriteLine(":: Performing build target " + buildTarget.ToString());
var buildPath = GetBuildPath();
var buildName = GetBuildName();
var fixedBuildPath = GetFixedBuildPath(buildTarget, buildPath, buildName);
var scenes = GetEnabledScenes();
Console.WriteLine(":: Build Scenes " + string.Join(",", scenes));
var buildReport = BuildPipeline.BuildPlayer(scenes, fixedBuildPath, BuildTarget.Android, BuildOptions.None);
if (buildReport.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
throw new Exception($"Build ended with {buildReport.summary.result} status");
Console.WriteLine(":: Done with build");
}
The android build file size from above script is 39M, while build from editor file size is 45M. Of course, game run error with smaller file size built.