Question by
Ramadhan_38 · Mar 26, 2018 at 01:12 AM ·
buildsizemobile devicesfile sizeheadless
Apk and Ipa get bigger file size when building using headless / command line
Hi, i was using gitlab continuous integration and got my build script below, when i was build unity project to apk and ipa, i got file size 4 times bigger than manual build directly from unity editor from 224mb (headless) to 54mb (manual), i was using asset bundle and i think it might the problem, have someone ever experiencing this problem and has the answer, Thank you...
private static void SetupPlayerOptions(BuildTargetGroup buildTargetGroup, BuildTarget buildTarget, string outputPath)
{
// Set a specific bundle identifier
PlayerSettings.SetApplicationIdentifier(buildTargetGroup, appIdentifier);
//Set Scripting Define Symbol
PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, scriptingDefineSymbol);
// Switch active build target
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget);
// Setup BuildPlayerOptions and build project
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
buildPlayerOptions.scenes = GetScenePaths();
buildPlayerOptions.locationPathName = outputPath;
buildPlayerOptions.target = buildTarget;
buildPlayerOptions.options = BuildOptions.None;
BuildPipeline.BuildPlayer(buildPlayerOptions);
}
// Build function for Android
public static void BuildAndroid()
{
string fileName = "Unity-Android.apk";
string outputPath = "Builds/Android/" + fileName;
// Set Android SDK & JDK path for Unity
EditorPrefs.SetString("AndroidSdkRoot", androidSdkPath);
EditorPrefs.SetString("AndroidJdkRoot", androidJdkPath);
SetupPlayerOptions(BuildTargetGroup.Android, BuildTarget.Android, outputPath);
}
// Build function for iOS
public static void BuildiOS()
{
string outputPath = "Builds/iOS";
SetupPlayerOptions(BuildTargetGroup.iOS, BuildTarget.iOS, outputPath);
}
Comment
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.AR$$anonymous$$64 | AndroidArchitecture.AR$$anonymous$$v7 ; PlayerSettings.SetIl2CppCompilerConfiguration(build_target_group, Il2CppCompilerConfiguration.Release); PlayerSettings.stripEngineCode = true;
this helped me.