You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Android] Build Report Inspector generates "apkanalyzer failed to estimate the apk size. Output: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8" exception on Build when using Java Environment Variable
#29
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
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)
The text was updated successfully, but these errors were encountered:
There is a branch named "seans/fix-jkd-issues" which has some fix.
that does not seem to solve the issue mentioned above - but a hacky solution just to get it running if you dont care about overall file size:
AndroidUtilities.cs #238 -> #258
int exitCode = 0;
long result = 0;
if (File.Exists(apkAnalyzerPath))
{
var apkAnalyzerArgs = $"apk download-size \"{applicationPath}\"";
apkAnalyzerOutput = Utilities.RunProcessAndGetOutput(apkAnalyzerPath, apkAnalyzerArgs, out exitCode);
}
else
{
var javaExecutablePath = GetJavaExecutablePath();
var apkAnalyzerArgs = $"{GetApkAnalyzerJavaArgs()} apk download-size \"{applicationPath}\"";
apkAnalyzerOutput = "0";// Utilities.RunProcessAndGetOutput(javaExecutablePath, apkAnalyzerArgs, out exitCode);
result = 0;
}
if (exitCode != 0)// || !long.TryParse(apkAnalyzerOutput, out var result))
{
throw new Exception($"apkanalyzer failed to estimate the apk size. Output:\n{apkAnalyzerOutput}");
}
return result;
Transferred from Jira (UUM-19493) because this ticket is a bug in the BuildReportInspector.
How to reproduce:
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\[email protected]\Editor\Mobile\AndroidUtilities.cs:253
at Unity.BuildReportInspector.Mobile.AndroidUtilities.GetArchitectureInfo (System.String applicationPath) [0x000f3] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\AndroidUtilities.cs:128
at Unity.BuildReportInspector.Mobile.MobileAppendix..ctor (System.String applicationPath) [0x000d8] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\MobileAppendix.cs:90
at Unity.BuildReportInspector.Mobile.MobileHelper.GenerateMobileAppendix (System.String applicationPath, System.String guid) [0x0001e] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\MobileHelper.cs:77
UnityEngine.Debug:LogError (object)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateMobileAppendix (string,string) (at Library/PackageCache/[email protected]/Editor/Mobile/MobileHelper.cs:83)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateAndroidAppendix (string,string) (at Library/PackageCache/[email protected]/Editor/Mobile/MobileHelper.cs:27)
Unity.BuildReportInspector.Mobile.PostBuildSetup:BuildPostProcess (UnityEditor.BuildTarget,string) (at Library/PackageCache/[email protected]/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:
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)
The text was updated successfully, but these errors were encountered: