-
Notifications
You must be signed in to change notification settings - Fork 382
detect ANDROID_SDK_ROOT #5502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detect ANDROID_SDK_ROOT #5502
Changes from all commits
c85f725
c392e45
7496678
5751bac
c208716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System.Threading.Tasks; | ||
using Microsoft.Diagnostics.NETCore.Client; | ||
using Microsoft.Extensions.Logging; | ||
using Xamarin.Android.Tools; | ||
|
||
namespace Microsoft.Diagnostics.Tools.DiagnosticsServerRouter | ||
{ | ||
|
@@ -65,7 +66,27 @@ public static void AdbRemovePortReverse(int localPort, int remotePort, bool owns | |
|
||
public static bool RunAdbCommandInternal(string command, string expectedOutput, int expectedExitCode, bool rethrow, ILogger logger) | ||
{ | ||
string sdkRoot = Environment.GetEnvironmentVariable("ANDROID_SDK_ROOT"); | ||
void sdklogger(TraceLevel level, string message) | ||
{ | ||
switch (level) | ||
{ | ||
case TraceLevel.Error: | ||
logger?.LogError(message); | ||
break; | ||
case TraceLevel.Warning: | ||
logger?.LogWarning(message); | ||
break; | ||
case TraceLevel.Info: | ||
logger?.LogInformation(message); | ||
break; | ||
case TraceLevel.Verbose: | ||
logger?.LogDebug(message); | ||
break; | ||
} | ||
}; | ||
|
||
// AndroidSdkInfo checks $ANDROID_SDK_ROOT, $ANDROID_HOME, and default locations. | ||
string sdkRoot = new AndroidSdkInfo(logger: sdklogger).AndroidSdkPath; | ||
string adbTool = "adb"; | ||
|
||
if (!string.IsNullOrEmpty(sdkRoot)) | ||
|
@@ -166,7 +187,7 @@ public override void Start() | |
_ownsPortReverse = false; | ||
Logger.LogError("Failed setting up adb port reverse." + | ||
" This might lead to problems communicating with Android application." + | ||
" Make sure env variable ANDROID_SDK_ROOT is set and points to an Android SDK." + | ||
" Make sure env variable $ANDROID_HOME is set and points to an Android SDK." + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably update our docs as well, https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dsrouter, it reference ANDROID_SDK_ROOT as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one updates the docs to match this PR: |
||
$" Executing with unknown adb status for port {_localPort}."); | ||
base.Start(); | ||
return; | ||
|
@@ -245,7 +266,7 @@ public override void Start() | |
_ownsPortForward = false; | ||
Logger.LogError("Failed setting up adb port forward." + | ||
" This might lead to problems communicating with Android application." + | ||
" Make sure env variable ANDROID_SDK_ROOT is set and points to an Android SDK." + | ||
" Make sure env variable $ANDROID_HOME is set and points to an Android SDK." + | ||
$" Executing with unknown adb status for port {_localPort}."); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably always going to be "preview" branded and marked as a non-shipping/transport package.
We could track with a subscription, but you probably don't need to update this frequently.
I can manage updating it manually when it matters, such as:
> darc update-dependencies --id 276447