Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/Xamarin.Android.Build.Debugging.Tasks/Tasks/RunActivity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//
#nullable enable
//
// RunActivity.cs
//
// Author:
Expand Down Expand Up @@ -41,12 +42,12 @@ public class RunActivity : AsyncTask
public override string TaskPrefix => "RUNA";

[Required]
public string PackageName { get; set; }
public string PackageName { get; set; } = "";

[Required]
public string ActivityName { get; set; }
public string ActivityName { get; set; } = "";

public string AdbTarget { get; set; }
public string? AdbTarget { get; set; }

public bool AttachDebugger { get; set; }

Expand All @@ -63,7 +64,7 @@ public class RunActivity : AsyncTask
/// </summary>
public bool AllowJavaDebugging { get; set; } = true;

AndroidDevice Device;
AndroidDevice? Device;

public RunActivity ()
{
Expand All @@ -84,6 +85,10 @@ public async override System.Threading.Tasks.Task RunTaskAsync ()
{
LogDebugMessage ($" ActivityName: {ActivityName}");

var device = Device;
if (device == null)
throw new System.InvalidOperationException ("The Android device must be initialized before running the task.");

var amStartCommand = new AmStartCommand (PackageName, ActivityName);
amStartCommand.ForceStop = ForceStop;
amStartCommand.EnableDebugging = false;
Expand All @@ -104,9 +109,9 @@ public async override System.Threading.Tasks.Task RunTaskAsync ()
startConfiguration.Debugger.StdoutPort = -1;
startConfiguration.Debugger.Server = Server;
LogMessage (string.Format (Resources.StartDebugger_ipAddress_port, ipAddress, port), MessageImportance.High);
await Device.StartWithDebuggingAsync (startConfiguration, CancellationToken);
await device.StartWithDebuggingAsync (startConfiguration, CancellationToken);
} else {
await Device.StartWithoutDebuggingAsync (startConfiguration, CancellationToken);
await device.StartWithoutDebuggingAsync (startConfiguration, CancellationToken);
}
}
}
Expand Down
Loading