Skip to content

Commit 73e942f

Browse files
committed
install apk: display error message if failed
1 parent a8a49f7 commit 73e942f

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

Diff for: UnityLauncherPro/MainWindow.xaml.cs

+28-14
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ private void Window_Closing(object sender, CancelEventArgs e)
11961196
CloseHubPipeAsync();
11971197
}
11981198

1199-
private void CloseThemeEditor()
1199+
private void CloseThemeEditor()
12001200
{
12011201
if (themeEditorWindow != null) themeEditorWindow.Close();
12021202
}
@@ -3583,24 +3583,38 @@ private void menuInstallLastAPK_Click(object sender, RoutedEventArgs e)
35833583
pars += $" && adb shell monkey -p {packageName} 1";
35843584
}
35853585

3586-
//Tools.LaunchExe(cmd, pars);
3587-
var process = Tools.LaunchExe(cmd, pars, captureOutput: true);
3588-
var output = process.StandardOutput.ReadToEnd();
3589-
var errorOutput = process.StandardError.ReadToEnd().Replace("\r", "").Replace("\n", "");
3586+
try
3587+
{
3588+
//Tools.LaunchExe(cmd, pars);
3589+
var process = Tools.LaunchExe(cmd, pars, captureOutput: true);
3590+
var output = process.StandardOutput.ReadToEnd();
3591+
var errorOutput = process.StandardError.ReadToEnd().Replace("\r", "").Replace("\n", "");
35903592

3591-
process.WaitForExit();
3593+
process.WaitForExit();
35923594

3593-
// Console.WriteLine(output);
3594-
if (!string.IsNullOrEmpty(errorOutput))
3595+
// Console.WriteLine(output);
3596+
if (!string.IsNullOrEmpty(errorOutput))
3597+
{
3598+
SetStatus("Error installing APK: " + errorOutput);
3599+
}
3600+
else
3601+
{
3602+
// get apk name from path
3603+
var apkName = Path.GetFileName(playerPath);
3604+
if (chkStreamerMode.IsChecked == true) apkName = " (hidden in streamermode)";
3605+
SetStatus("Installed APK:" + apkName);
3606+
}
3607+
3608+
}
3609+
catch (Win32Exception ex)
35953610
{
3596-
SetStatus("Error installing APK: " + errorOutput);
3611+
// Handle case where 'adb' is not found
3612+
SetStatus($"Error: 'adb' not found. Ensure it's installed and added to PATH. Details: {ex.Message}");
35973613
}
3598-
else
3614+
catch (Exception ex)
35993615
{
3600-
// get apk name from path
3601-
var apkName = Path.GetFileName(playerPath);
3602-
if (chkStreamerMode.IsChecked == true) apkName = " (hidden in streamermode)";
3603-
SetStatus("Installed APK:" + apkName);
3616+
// Handle other unexpected exceptions
3617+
SetStatus($"An unexpected error occurred: {ex.Message}");
36043618
}
36053619
}
36063620

0 commit comments

Comments
 (0)