Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created October 20, 2025 04:25
Show Gist options
  • Select an option

  • Save baba-s/b0860fd953eabfe1aab2ca5fa3238223 to your computer and use it in GitHub Desktop.

Select an option

Save baba-s/b0860fd953eabfe1aab2ca5fa3238223 to your computer and use it in GitHub Desktop.
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