JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
269 stars 10 forks source link

The Android SDK directory could not be found. Android MAUI App development on Linux #65

Closed ghost closed 1 year ago

ghost commented 1 year ago

DotNet.Meteor is a great extension for running MAUI apps, but I have trouble building my project (MAUI Android app)

You see, project loading is a process every MAUI app gets through when it comes to development using VS Code. When the project is being loaded on Windows (VS Code), the C# extension (that uses Omnisharp) automatically finds the path to the android-sdk folder. But, if you're on Linux, you get the error:

[fail]: OmniSharp.MSBuild.ProjectLoader The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://aka.ms/dotnet-android-install-sdk To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path.

I tried to find a way to set this property, but it looks like no one has had the same error in VS Code. I have installed the android-sdk and I know the path, but how can I set it as a property? DotNet.Meteor won't detect the project unless it is loaded successfully

JaneySprings commented 1 year ago

Hello. Thank you for your issue! DotNet.Meteor does not require any additional extensions (like OmniSharp) to loading projects. If you will open your folder with project in the VSCode, DotNet.Meteor will automatically show a configuration and devices:

image

Do you have such buttons in the status bar as I have in the photo?

If no, try to see the log of the VSCode for errors. Go to Help \ Toggle Developer Tools -> Console

image
JaneySprings commented 1 year ago

As for the AndroidSdkLocation, DotNet.Meteor automatically finds AndroidSdk through known locations.

1) Check ANDROID_SDK_ROOT or ANDROID_HOME environmental variables. 2) Check default AndroidStudio location (/users/You/Android/Sdk for Linux) 3) Check default VisualStudio location (does not exists for Linux)

https://github.com/JaneySprings/DotNet.Meteor/blob/7539e3b1615e0bbc06d0f229427e9c2456b4939e/src/DotNet.Meteor.Shared/Android/PathUtils.cs#L7-L36

if you really need to change the AndroidSdkLocation, then the easiest way is to set the ANDROID_SDK_ROOT or ANDROID_HOME environment variable

ghost commented 1 year ago

I tried the extension on Windows and everything went well, but on Linux there are no .NET Meteor buttons on the status bar. I selected my project using the command .NET Meteor: Select workspace project

Also, I have no errors in the Developer Console except the ones I get as notifications (Please, select a device to debug etc) I selected the project, but my device (Android Phone) doesn't appear in the list (The list was also opened by running the command .NET Meteor: Select device I tried re-plugging my phone but it doesn't work

ghost commented 1 year ago

Microsoft released a new VS Code extension called .NET MAUI, which can be used to create and debug MAUI apps. I will try this extension to see if my Linux device can recognize the Android Phone I use. I will let you know if it is a problem on my side, but the buttons on the status bar still not appeared, I hope to figure out what causes it.

JaneySprings commented 1 year ago

Can you try to specify your custom path to AndroidSdkLocation that I mentioned above?

if you really need to change the AndroidSdkLocation, then the easiest way is to set the ANDROID_SDK_ROOT or ANDROID_HOME environment variable

ghost commented 1 year ago

/opt/android-sdk

JaneySprings commented 1 year ago

yes, I think if you set this value to ANDROID_HOME or ANDROID_SDK_ROOT environmental variable, then everything will work