/// <summary> /// Builds an Android App Bundle at a user-specified file location. /// </summary> public static void Build() { #if !PLAY_INSTANT_ENABLE_NATIVE_ANDROID_APP_BUNDLE if (!AndroidAssetPackagingTool.CheckConvert()) { return; } if (!Bundletool.CheckBundletool()) { return; } #endif if (!PlayInstantBuilder.CheckBuildAndPublishPrerequisites()) { return; } // TODO: add checks for preferred Scripting Backend and Target Architectures. var aabFilePath = EditorUtility.SaveFilePanel("Create Android App Bundle", null, null, "aab"); if (string.IsNullOrEmpty(aabFilePath)) { // Assume cancelled. return; } Build(aabFilePath); }
/// <summary> /// Builds an APK and stores it in a user specified ZIP file. /// </summary> public static void Build() { if (!PlayInstantBuilder.CheckBuildAndPublishPrerequisites()) { return; } var zipFilePath = EditorUtility.SaveFilePanel("Create APK in ZIP File", null, null, "zip"); if (string.IsNullOrEmpty(zipFilePath)) { // Assume cancelled. return; } #if UNITY_2018_3_OR_NEWER EditorUserBuildSettings.buildAppBundle = false; #endif var baseApkDirectory = Path.GetTempPath(); var baseApkPath = Path.Combine(baseApkDirectory, BaseApkFileName); Debug.LogFormat("Building APK: {0}", baseApkPath); var buildPlayerOptions = PlayInstantBuilder.CreateBuildPlayerOptions(baseApkPath, BuildOptions.None); if (!PlayInstantBuilder.BuildAndSign(buildPlayerOptions)) { // Do not log here. The method we called was responsible for logging. return; } // Zip creation is fast enough so call jar synchronously rather than wait for post build AppDomain reset. var zipFileResult = ZipUtils.CreateZipFile(zipFilePath, baseApkDirectory, BaseApkFileName); if (zipFileResult == null) { Debug.LogFormat("Created ZIP file: {0}", zipFilePath); } else { PlayInstantBuilder.DisplayBuildError(string.Format("Zip creation failed: {0}", zipFileResult)); } }