-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Transferred from Jira (UUM-19493) because this ticket is a bug in the BuildReportInspector.
How to reproduce:
- Go to “Edit the system environment variables” > “Environment Variables…” > “New”
- Add “JAVA_TOOL_OPTIONS“ as a Variable name and “-Dfile.encoding=UTF-8“ as a Variable value
- Create a new Unity project
- Go to “Package Manager“ > “Add package from git URL“ and add “com.unity.build-report-inspector“ URL
- Build for Android
- After the Build is complete observe the Console
Expected result: There are no exceptions
Actual result: “System.Exception: apkanalyzer failed to estimate the apk size. Output: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8“ exception appears
Reproducible with: 0.2.2-preview, 0.3.0-preview (2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16, 2023.1.0a20)
Not reproducible on: iOS, Standalone Player (Windows 11)
Note: After setting Environment Variable a Unity Hub / PC restart may be needed
Full exception message:
System.Exception: apkanalyzer failed to estimate the apk size. Output:
18131288
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
at Unity.BuildReportInspector.Mobile.AndroidUtilities.GetApkDownloadSize (System.String applicationPath) [0x001e5] in Project Path\Library\PackageCache\com.unity.build-report-inspector@0.3.0-preview\Editor\Mobile\AndroidUtilities.cs:253
at Unity.BuildReportInspector.Mobile.AndroidUtilities.GetArchitectureInfo (System.String applicationPath) [0x000f3] in Project Path\Library\PackageCache\com.unity.build-report-inspector@0.3.0-preview\Editor\Mobile\AndroidUtilities.cs:128
at Unity.BuildReportInspector.Mobile.MobileAppendix..ctor (System.String applicationPath) [0x000d8] in Project Path\Library\PackageCache\com.unity.build-report-inspector@0.3.0-preview\Editor\Mobile\MobileAppendix.cs:90
at Unity.BuildReportInspector.Mobile.MobileHelper.GenerateMobileAppendix (System.String applicationPath, System.String guid) [0x0001e] in Project Path\Library\PackageCache\com.unity.build-report-inspector@0.3.0-preview\Editor\Mobile\MobileHelper.cs:77
UnityEngine.Debug:LogError (object)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateMobileAppendix (string,string) (at Library/PackageCache/com.unity.build-report-inspector@0.3.0-preview/Editor/Mobile/MobileHelper.cs:83)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateAndroidAppendix (string,string) (at Library/PackageCache/com.unity.build-report-inspector@0.3.0-preview/Editor/Mobile/MobileHelper.cs:27)
Unity.BuildReportInspector.Mobile.PostBuildSetup:BuildPostProcess (UnityEditor.BuildTarget,string) (at Library/PackageCache/com.unity.build-report-inspector@0.3.0-preview/Editor/Mobile/PostBuildSetup.cs:44)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Details:
Notes from Julius Miknevicius:
Build Report Inspector package tries to parse the whole apkanalyzer output as long
https://github.com/Unity-Technologies/BuildReportInspector/blob/master/com.unity.build-report-inspector/Editor/Mobile/AndroidUtilities.cs#L247
however when JAVA_TOOL_OPTIONS environment variable is specified, the output of apkanalyzer is:
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
20964989
20964989 is the size of the apk, which is what build report inspector wants.
So it seems the fix would be to improve the parsing code to strip off that possible extra junk in the output (or find a way to invoke the tool so that it doesn't add that unexpected noise in its output)