Set up VS Code environment for MAUI .NET 8 - Android

1.2k Views Asked by At

I am desperately trying to set everything up on VS Code for Mac in order to be able to build and release MAUI .NET 8 apps. I also have a MAUI .NET 7 which I actually develop and build on VS for Mac 2022, but I will soon need to migrate it to this new IDE. When I perform the dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True suggested command, I get the following output:

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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "platforms;android-34"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "build-tools;34.0.0"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "platform-tools"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "cmdline-tools;11.0"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "platforms;android-34"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "build-tools;34.0.0"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "platform-tools"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.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/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin/sdkmanager --install "cmdline-tools;11.0"` [/Users/michelewilliammanco/Projects/TestNET/TestNET.csproj::TargetFramework=net8.0-android]
    4 Warning(s)
    0 Error(s)

The issue is that I can't properly resolve the wanted SDK. I tried several times to install all the packages mentioned in the warnings using the sdkmanager executable in /Users/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/11.0/bin but it would say that the executable has been compiled with a more recent version of Java. If I try to execute the same command from /Users/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/7.0/bin it seems to work, but then nothing changes and the tools should have been installed but could not resolved anyway. I am stuck in this weird situation. Consider also that, VS for Mac 2022 doesn't give me the possibility to install new Android SDK anymore, since it will be soon dismissed. I would, if possible, like to avoid installing Android Studio for this SDK stuff, rather preferring to go through by CLI. Do you have any idea on what is it annoying the MSBuild?

1

There are 1 best solutions below

0
ImproveSoftware On

I finally solved the issue by:

  • installing cmdline-tools;11.0 with /Users/michelewilliammanco/Library/Developer/Xamarin/android-sdk-macosx/cmdline-tools/7.0/bin/sdkmanager --install "cmdline-tools;11.0"
  • installing everything else from the same path and using sdkmanager. It's good to know that for everything to be updated, the right folder from which to execute sdkmanager is 7.0 and not 11.0.

At the end of the procedure, my VS Code says everything is installed, updated and ready for development.