Created
October 20, 2025 04:25
-
-
Save baba-s/b0860fd953eabfe1aab2ca5fa3238223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| using System.IO; | |
| using UnityEditor.Android; | |
| namespace Kogane | |
| { | |
| public static class AppBundleInstaller | |
| { | |
| public static void Install( string aabFileName ) | |
| { | |
| var currentDirectory = Directory | |
| .GetCurrentDirectory() | |
| .Replace( "\\", "/" ) | |
| ; | |
| var arguments = $@"export ANDROID_HOME={AndroidExternalToolsSettings.sdkRootPath} | |
| export PATH=$PATH:$ANDROID_HOME/platform-tools | |
| JAVA_PATH=""{AndroidExternalToolsSettings.jdkRootPath}/bin/java"" | |
| BUNDLE_TOOL_PATH=""{AndroidBundletoolPath.Value}"" | |
| APKS_PATH=""{currentDirectory}/{Path.GetFileNameWithoutExtension( aabFileName )}.apks"" | |
| AAB_PATH=""{currentDirectory}/{aabFileName}"" | |
| rm -f ""${{APKS_PATH}}"" | |
| ""${{JAVA_PATH}}"" \ | |
| -jar \ | |
| ""${{BUNDLE_TOOL_PATH}}"" \ | |
| build-apks \ | |
| --bundle=""${{AAB_PATH}}"" \ | |
| --output=""${{APKS_PATH}}"" \ | |
| --mode=universal | |
| ""${{JAVA_PATH}}"" \ | |
| -jar \ | |
| ""${{BUNDLE_TOOL_PATH}}"" \ | |
| install-apks \ | |
| --apks=""${{APKS_PATH}}"" | |
| "; | |
| UnityEngine.Debug.Log( arguments ); | |
| var startInfo = new ProcessStartInfo | |
| { | |
| FileName = "/bin/bash", | |
| Arguments = $"-c \"{arguments.Replace( "\"", "\\\"" )}\"", | |
| UseShellExecute = false, | |
| RedirectStandardOutput = true, | |
| RedirectStandardError = true, | |
| CreateNoWindow = true, | |
| }; | |
| using var process = new Process(); | |
| process.StartInfo = startInfo; | |
| process.OutputDataReceived += ( _, e ) => UnityEngine.Debug.Log( e.Data ); | |
| process.ErrorDataReceived += ( _, e ) => UnityEngine.Debug.Log( e.Data ); | |
| process.Start(); | |
| process.BeginOutputReadLine(); | |
| process.BeginErrorReadLine(); | |
| process.WaitForExit(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment