-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 8 Preview 6 MAUI project fails to build for Android in the command line as it's unable to detect the Android SDK path #16091
Comments
For the time being, have found a workaround for building the project for the Android platform from CLI. The Android SDK path is controlled by the MSBuild project property named Pass the correct SDK path as a value for this property while executing the dotnet build -f net8.0-android -p:AndroidSdkDirectory=%LocalAppData%\Android\Sdk As usual for running the project, add the Ideally, dotnet CLI should refer to the location from somewhere in a hierarchy, but it failed to do so in this preview version. This needs to be looked into as builds on CI solely rely on these commands. Pro Tip: This can be written as a batch file to automate the process so that it need not be typed again and again. %LocalAppData% is an OS environment variable that will automatically point to the current user's local application data directory. |
Seems like I found the core problem, .NET CLI is proactively making use of a single quote ( The below command with the value within the single quotes is failing with the same error as like without the dotnet build -f net8.0-android -p:AndroidSdkDirectory='%LocalAppData%\Android\Sdk' Whereas the value within the double quotes works perfectly fine. dotnet build -f net8.0-android -p:AndroidSdkDirectory="%LocalAppData%\Android\Sdk" |
Referencing this comment as it describes this issue in simple terms. |
If the issue is indeed changing JavaScript code to use double quotes (instead of single). We can probably close the issue here. @egvijayanand did you notice a problem in ordering of finding the Android SDK? (code for this is here) I wonder if the logic is always going to prefer the value set in Visual Studio, and this would prevent you from using environment variables like |
Hi @egvijayanand. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. |
I am facing another issue when I run the command dotnet build in the dotnetMAUI App project in visual studio 2022 Unable to understand this issue. @egvijayanand @maddymontaquila @jonathanpeppers |
Hi @SoumyadipYT-OSS, If you're running .NET MAUI on .NET 8, you need to have Android SDK 34. First check the location where Android SDK is pointing to: VS2022 -> Tools -> Options -> Xamarin -> SDK Location Then check whether this folder If not, install and then try. |
Hi @egvijayanand, |
Try this: dotnet build -f net8.0-android -p:AndroidSdkDirectory=<path_here> You need to pass the location of the SDK directory as the value to the MSBuild property. If the path contains space, surround it with quotes. |
After implementing this code C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.43\tools\Xamarin.Android.Toolin Build FAILED. C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.43\tools\Xamarin.Android.Toolin |
AndroidSdkDirectory should point only to the root directory. dotnet build -f net8.0-android -p:AndroidSdkDirectory=E:\Android\android-sdk |
And what's your Xamarin Setting has inside VS2022 @SoumyadipYT-OSS , if it's the same path. Then @jonathanpeppers kindly reopen the issue. It's not yet resolved. |
@egvijayanand how to find the path of Xamarin Setting has inside VisualStudio2022? |
Check earlier comment👆 |
@egvijayanand Thank you issue solved. Have a great day |
Description
.NET 8 Preview 6 MAUI project fails to build for Android in the command line as it's unable to detect the Android SDK path.
Android SDK is installed in the
%LocalAppData%\Android\Sdk
folder on my machine.And .NET CLI is repeatedly looking for the SDK from the Program Files folder.
After installing the latest preview version of VS2022 (17.7 Preview 3.0), found that the Android SDK path is reset to Program Files, have manually modified the setting to rightly point it to the Local AppData folder.
VS Setting:
Xamarin -> Android Settings -> Android SDK Location
Post update of this setting, it is working inside VS IDE.
But it fails to build on the CLI.
Have tried setting the ANDROID_HOME and ANDROID_SDK_ROOT environment variables and even added the path to the PATH environment variable. But ended in vain as it always looks for the Android SDK from the Program Files folder (refer to the log section).
Note: Have selected the Version with bug field as Unknown/Other as the .NET 8 Preview 6 is not yet added.Steps to Reproduce
Link to public reproduction project repository
Default template itself is suffice, no authored code
Version with bug
8.0.0-preview.6.8686
Last version that worked well
8.0.0-preview.5.8529
Affected platforms
Android
Affected platform versions
Android 34.0
Did you find any workaround?
Validate and Update, if necessary, the value of Android SDK location within VS IDE. That's the only option for now.
Refer to the comments for a workaround.
Relevant log output
The text was updated successfully, but these errors were encountered: