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

Wrong Android SDK path is selected #33

Closed jfversluis closed 1 year ago

jfversluis commented 1 year ago

When trying to run my project on Android I'm faced with the error below

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.4/tools/Xamarin.Android.Tooling.targets(100,5): error XA5207: Could not find android.jar for API level 33. This means the Android SDK platform for API level 33 is not installed. Either install it in the Android SDK Manager (Tools > Open Android SDK Manager...), or change the Xamarin.Android project to target an API version that is installed. (/Users/jfversluis/Library/Android/Sdk/platforms/android-33/android.jar missing.) [/Users/jfversluis/Source/Maui-toolkit/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj::TargetFramework=net7.0-android]

Strange thing is that the exact same project does work from Visual Studio for Mac. When comparing the path that is passed in from this extension and where the Android SDK is installed according to VS for Mac, it seems that there is a mixup there:

Meteor: -p:AndroidSdkDirectory="/Users/jfversluis/Library/Android/Sdk"

VSMac: /Users/jfversluis/Library/Developer/Xamarin/android-sdk-macosx

Maybe this is not typical for everyone, but maybe it would be good to improve the search path and/or some way to configure the SDK path manually?

JaneySprings commented 1 year ago

Hello! To find the Android SDK, the Meteor extension uses the 'ANDROID_SDK_ROOT' environmental variable value. If this value is not specified, meteor tries to find the Android SDK in the default location defined by Android Studio. https://github.com/JaneySprings/DotNet.Meteor/blob/988fd8b9eac4eb59deb05bd241235d0401de1edc/src/DotNet.Meteor.Shared/Android/PathUtils.cs#L8-L22

In your particular case, you can do any of the following:

jfversluis commented 1 year ago

Awesome, thanks for the quick responses and fixes/workarounds!

jfversluis commented 1 year ago

I guess this is not so much an issue outside of my environment then and this one can be closed.