Unity checks for APK size after build AAB

I am running the following code (in file) to build an AAB file. (main code line*: EditorUserBuildSettings.buildAppBundle = true;*)

Unity builds correctly the AAB file, however after that, in PostProcess, Unity log says: Checking APKs size, what causes an error "FileNotFoundException: Could not find file ‘*.apk’. ", (obviously because APK was not built) and the build stops.

Why Unity is looking for APK size, and how to skip that step?

Configuration:
Unity 2019.2.0

5334546–537975–UnityBuildAndroidFunction.cs (2.39 KB)

You can build an aab directly from Unity, but I’m guessing you require a command line build. You select Build App Bundle (Google Play) checkbox in the Build Setting dialog. In the file you posted, it directly references an apk file name

buildPlayerOptions.locationPathName = string.Format(“{0}.apk”,

Yes, sure; I got the code and did not realize that.

It works now. Thank you!

This issue still occurs on 2019.4.4f1 when doing command line build. Could you specify what you need to do to fix command line build? As in old response you speak of UI element that you won’t access when doing command line build. Our builder does not change default buildPlayerOptions.locationPathName.

Sharing my issue:
Our previous setup was on Unity2018, where we used **BuildPipeline.BuildPlayer(scenes, apkName, BuildTarget.Android, buildOptions);**

After updating to Unity2019, this caused the "Checking APK’s size…FileNotFoundException: Could not find file ‘*.apk’. " error. To fix this, I had to check apkName for “.apk” and simply replaced it with “.aab”