microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
234 stars 13 forks source link

cmdline-tools not detected if 16.0.0-rc1 is installed #1404

Open samhouts opened 3 months ago

samhouts commented 3 months ago

Type: Bug

I had both the latest and version 11.0 installed for cmdline-tools. The Android setup never recognized that 11 was installed until I uninstalled latest.

Extension version: 1.3.3 VS Code version: Code - Insiders 1.93.0-insider (Universal) (e81aceaa07bab1ccdc94deae04168c8bd062f0de, 2024-08-26T05:04:02.640Z) OS version: Darwin arm64 23.6.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M3 Pro (12 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|1, 1, 1| |Memory (System)|36.00GB (0.15GB free)| |Process Argv|--crash-reporter-id 1af4bb54-8360-4959-908c-8225cba31b88| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 vsaa593:30376534 py29gd2263:31024238 c4g48928:30535728 962ge761:30841072 pythongtdpath:30726887 welcomedialog:30812478 pythonnoceb:30776497 asynctok:30898717 dsvsc014:30777825 dsvsc015:30821418 pythonregdiag2:30926734 pythonmypyd1:30859725 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 cppperfnew:30980852 pythonait:30973460 g316j359:31013175 a69g1124:31018687 dvdeprecation:31040973 dwnewjupytercf:31046870 nb_pri_only:31057983 nativerepl1:31104042 refactort:31084545 pythonrstrctxt:31093868 flighttreat:31119334 wkspc-onlycs-t:31111718 nativeloc1:31118317 wkspc-ranged-c:31125598 cf971741:31111988 fcdif617:31111928 e80f6927:31120813 ei213698:31121563 12bdf347:31121875 ```

| VS Bug 2242188

jonpryor commented 3 months ago

I'd edit the title, but I can't, so I won't.

For my own clarification: When only cmdline-tools 16.0.0-rc1 is installed, it isn't detected.

Aside: How is "16.0.0-rc1" being installed?! The current Google repository manifest doesn't have a 16.0.0-rc1! It has a "16.0-alpha1"! (The answer is "Koala", but how is Koala finding 16.0.0-rc1?!). I'm less certain about what this means, and I don't want to use Koala to find out. (What's "Koala"?!)

The Setup

Create a "clean" Android SDK, ensure it builds:

dotnet new android
dotnet build -t:InstallAndroidDependencies -p:AndroidSdkDirectory=`pwd`.sdk -p:JavaSdkDirectory=`pwd`.jdk -p:AcceptAndroidSDKLicenses=True
dotnet build -p:AndroidSdkDirectory=`pwd`.sdk -p:JavaSdkDirectory=`pwd`.jdk -v:diag > b.cmdline-11.txt
# no errors

No cmdline-tools?

What if there is no cmdline-tools?

(cd `pwd`.sdk && mv cmdline-tools/11.0 cmdline-tools/__11.0__)
rm -Rf bin obj
dotnet build -p:AndroidSdkDirectory=`pwd`.sdk -p:JavaSdkDirectory=`pwd`.jdk -v:diag > b.no-cmdline.txt

…and it builds, no errors. This is seemingly because cmdline-tools isn't "needed" by the build. If I search for sdk/cmdline-tools in the b*.txt log files, when there is a cmdline-tools/11.0 directory, b.cmdline-11.txt contains:

Output Property: _AndroidToolsDirectory=…/android-iad-nojdk.sdk/cmdline-tools/11.0
Output Property: LintToolPath=…/android-iad-nojdk.sdk/cmdline-tools/11.0/bin
Set Property: _DefaultLintToolPath=…/android-iad-nojdk.sdk/cmdline-tools/11.0/bin

vs. the build without cmdline-tools in b.no-cmdline.txt:

Output Property: _AndroidToolsDirectory=/Users/jon/Downloads/tmp/android-iad-nojdk.sdk/tools
Set Property: _DefaultLintToolPath=…/android-iad-nojdk.sdk/cmdline-tools/11.0/bin

So the $(_AndroidToolsDirectory) value is crazy "old" (yet we still provision the obsolete tools package!), and LintToolPath isn't set at all, and $(_DefaultLintToolPath) refers to a directory that does not exist.

But it built! :shrug:

…and I wasn't using anything that involved $(LintToolPath), which isn't used in a default build…

What does "not detected" mean

@samhouts: what does this mean?

I had both the latest and version 11.0 installed for cmdline-tools. The Android setup never recognized that 11 was installed until I uninstalled latest.

what is "Android setup"? How to I get "Android setup" to attempt to recognize cmdline-tools 11?

Is "Android setup" VSCode Settings > Extensions > .NET MAUI > Android Sdk Preferred Path? That doesn't appear to do any validation (or if it does, I don't know how to trigger it).

If I go to my "newly modified" Android SDK directory and then install 16.0-alpha1 into a "latest" directory:

curl -o commandlinetools-mac-12172612_latest.zip https://dl-ssl.google.com/android/repository/commandlinetools-mac-12172612_latest.zip
unzip commandlinetools-mac-12172612_latest.zip
mv cmdline-tools latest

such that path/to/android/sdk/cmdline-tools/latest/source.properties contains:

Pkg.Revision=16.0-alpha01
Pkg.Path=cmdline-tools;16.0-alpha01
Pkg.Desc=Android SDK Command-line Tools

I can use the "latest" cmdline-tools version by setting $(AndroidCommandLineToolsVersion)=latest:

dotnet build -p:AndroidSdkDirectory=`pwd`.sdk -p:JavaSdkDirectory=`pwd`.jdk \
  -p:AndroidCommandLineToolsVersion=latest -v:diag > b.latest.txt

No errors, and $(LintToolPath) is resolved as $(pwd).sdk/cmdline-tools/latest/bin, which is cool, I guess? (Not that it's used, as established when we didn't have cmdline-tools at all…)

I'm not sure where I'm going here, but I'm also not sure what "Android setup" is referring to either.

jonpryor commented 3 months ago

What is "Android setup"? Android setup:

  1. Within VSCode, open a project containing a .csproj targeting e.g. net8.0-android, e.g. from dotnet new maui or dotnet new android
  2. Within VSCode, type: ⌘ ⇧ P > .NET MAUI: Configure Android > Set Android SDK Path
  3. Select the directory containing the Android SDK, in my case $(pwd).sdk, then click Open
  4. In the lower-right of the VSCode window, a panel may appear: "Android install is required. Please check the .NET MAUI output window for more info." Buttons are Configure… and Show Output
  5. Click Show Output

The output panel contains:

    Android SDK recommended required components:
    x platforms/android-34: not installed.
    - build-tools/34.0.0: installed version '34.0.0'
    - platform-tools: installed version '34.0.5'
    x cmdline-tools/11.0: not installed.

which, as @samhouts noted, is odd, because cmdline-tools/11.0 does exist. (Or does once I restore it…)

So long as a cmdline-tools/latest directory exists, "Set Android SDK Path" is not happy.

Additionally, renaming cmdline-tools/latest to cmdline-tools/16.0 doesn't "fix" things either. cmdline-tools/11.0 must be the only directory in order for "Set Android SDK Path" to be happy.

jonpryor commented 3 months ago

This appears to be a dupe of #842, and seemingly the "Set Android SDK Path" validator is not happy unless only cmdline-tools/11.0 exists. If any other directory exists, it reports cmdline-tools/11.0: not installed, even if it is.