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
208 stars 7 forks source link

[BUG] .NET Maui Command Line Tools Not Installed #842

Open jbtdevgit opened 5 months ago

jbtdevgit commented 5 months ago

Describe the Issue

My cmdline-tools is not being detected by the .NET MAUI extension

User preferred Java SDK path stored on Settings: C:\Android\Android-Jdk
JAVA_HOME value found: C:\Android\Android-Jdk
Java SDK path to be used: C:\Android\Android-Jdk

User preferred Android SDK path stored on Settings: C:\Android\Android-Sdk\sdk
ANDROID_HOME value found: C:\Android\Android-Sdk\sdk
Android SDK path to be used: C:\Android\Android-Sdk\sdk

Android components:
    - Java SDK (version: '11.0.21'): installed.

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

    Android SDK recommended optional components:
    - emulator (version: '33.1.24'): installed.
    - system-images/android-34/google_apis/x86_64 (version: '8'): installed.

image

Steps To Reproduce

No response

Expected Behavior

No response

Environment Information

jbtdevgit commented 5 months ago

It seems like the cmdline tools version of https://developer.android.com/studio is v12.0. Do anyone knows where can I download the v11.0? So I can try if that would work.

mauroa commented 5 months ago

Assigning to @tondat to take a first look

jbtdevgit commented 5 months ago

Any news for this? Since it has been 2 weeks and we are using mac and vs mac is not an option for us anymore. Thank you.

jbtdevgit commented 5 months ago

We can now close this one, the extensions were updated and can finally see my cmdline tools shown below image

jbtdevgit commented 5 months ago

Re opening this issue, unfortunately Android cannot run with cmdline-tools of 12.0 shown on image below image

image

Android Studio can detect JDK/SDK properly. Launching has no issue as well.

image image image

jbtdevgit commented 4 months ago

Meh, I guess shutting down VS Mac is not a good idea if prioritisation of updates for tooling is this bad. Looks awful considering VS code is a recommended tool to develop a MAUI project for mac.

drasticactions commented 4 months ago

@tondat @mauroa Can this be looked at again please?

magnacartaam commented 4 months ago

I just out of despair renamed the Android/sdk/cmdline-tools/latest folder to Android/sdk/cmdline-tools/11.0 and maui found it and it works. I have 12.0 version of cmdline tools

mauroa commented 4 months ago

I replicated the work item internally and we will work on the fix. Good to know that the workaround of renaming the folders worked, at least to unblock the scenario. Thanks

DaveMcCrady commented 4 months ago

I just out of despair renamed the Android/sdk/cmdline-tools/latest folder to Android/sdk/cmdline-tools/11.0 and maui found it and it works. I have 12.0 version of cmdline tools

Can Confirm. " - cmdline-tools/11.0 (version: '12.0'): installed."

mauroa commented 3 months ago

This issue has been fixed, please install the latest VS Code MAUI pre-release in order to get the fix. Feel free to reopen this ticket in case you still experience any related issue. Thanks for your help.

fekberg commented 2 months ago

The work-around of renaming the folder to 11.0 does not work for me. Nor does it work with the latest pre-release.

maddymontaquila commented 2 months ago

Reopening this because a customer has reached out having this issue, details to follow

fekberg commented 2 months ago

Thanks @maddymontaquila, adding some details. Got a fairly newly setup machine with Rider, VS Code, Android SDK installed, and latest bits and pieces from .NET 8. Rider works just fine, pointing all settings for VS Code and the plugin to the same SDK and it still fails.

I tried issuing this from the command line: dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AndroidSdkDirectory="<AndroidSdkPath>" -p:JavaSdkDirectory="<JavaSdkPath>" -p:AcceptAndroidSDKLicenses=True

(with the correct paths) and that yields the following:

dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AndroidSdkDirectory="/Users/fekberg/Library/Android/sdk" -p:JavaSdkDirectory="/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home" -p:AcceptAndroidSDKLicenses=True
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platforms;android-34` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "platforms;android-34"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `build-tools;34.0.0` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "build-tools;34.0.0"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platform-tools` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "platform-tools"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `cmdline-tools;11.0` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "cmdline-tools;11.0"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]

Build succeeded.

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platforms;android-34` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "platforms;android-34"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `build-tools;34.0.0` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "build-tools;34.0.0"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platform-tools` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "platform-tools"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `cmdline-tools;11.0` should have been installed but could not be resolved. You can attempt to install it with: `/Users/fekberg/Library/Android/sdk/cmdline-tools/11.0/bin/sdkmanager --install "cmdline-tools;11.0"` [/Users/fekberg/Code/my-app/MyApp/MyApp.csproj::TargetFramework=net8.0-android]
    4 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.77

It's complaining about cmdline-tools not being installed, but it definitely is and I also tried the "hack" of copying/renaming the folder:

image

See here:

image

tondat commented 1 month ago

@fekberg Thank you for your feedback!

Could you try to install a new cmdline-tools with the following instructions:

1- open a terminal 2- move to folder <android-sdk>/cmdline-tools/11.0/bin

  1. run: ./sdkmanager "cmdline-tools;12.0"
  2. move to folder: <android-sdk>/cmdline-tools/12.0/bin
  3. run: ./sdkmanager --licenses --verbose
  4. remove folder <android-sdk>/cmdline-tools/11.0

If that does not work, as a workaround could you try to install a new android-sdk using the following instructions: Install android-sdk using the InstallAndroidDependencies target

After that, we need to configure the Android SDK to be used on MAUI by adding the MSBuild property AndroidSdkDirectory on the csproj file, or by specifying the Android SDK Preferred Path from the Settings page to determine the path at the user/workspace level. You can also set the ANDROID_HOME environment variable to define the path at machine level (recommended).

Please let me know if that works for you.

We look forward to hearing from you!

fekberg commented 1 month ago

@tondat Running ./sdkmanager gives me a LinkageError telling me the SdkManagerCli has been compiled with a more recent version of the Java Runtime.

The second part, about using InstallAndroidDependencies, that is exactly what I posted above isn't it? I've pointed it to the correct SDK path, I've set all environment variables but that still doesn't help.

billylo1 commented 3 weeks ago

My workaround is to remove the cmdline-tools/latest folder (I am not sure when it got installed, but it's there.. it's not a symbolic link, but a real directory.)

drwxr-xr-x   7 billylo  staff  224 26 May 09:21 11.0
drwxr-xr-x   7 billylo  staff  224 26 May 09:35 12.0
drwxr-xr-x   7 billylo  staff  224 26 May 08:34 13.0
drwxr-xr-x   7 billylo  staff  224 25 May 21:42 7.0
drwxr-xr-x   7 billylo  staff  224 25 May 21:11 latest