-
Notifications
You must be signed in to change notification settings - Fork 538
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
TargetFramework=net8.0-android33
gives poor error message
#8331
Comments
I'm seeing this error even if I remove
Can you provide any more details on why this error occurs? This is with RC2 |
Can you share a |
Thank you! Your suggestion lead to a solution :) I ran Here's the error I was getting in VS in case it helps someone else:
|
VS Mac has a checkbox that allows it to use the .NET 8 SDK. Maybe it is confused and mixing .NET 7 and 8? |
Good thought! Under Preferences > Preview Features, it was showing as selected. I unchecked the option, restarted, then selected the option, and restarted. The restore and build succeeds now. |
Hello, I'm also getting this error. When upgrading maui from .net 7 to .net 8. I tried your solutions.. Anything I can try? |
I am getting the same error as @ziomek64. I have run the "dotnet build" and "dotnet build -bl" commands in a terminal session, however, that did not solve the problem. I am in windows11 and the release vs 2022 as of November 14 and the released .net 8. I went into my project file, and I noticed that the one of the target platforms was net8.0-android33.0. I changed this to net8.0-android34.0, and the error in VS has gone away. Fingers crossed that this solves the problem. |
I did that but now I'm getting this following error: Severity Code Description Project File Line Suppression State ![]() |
You can just remove the If you want to set the minimum SDK version, you can do: <SupportedOSPlatformVersion>24</SupportedOSPlatformVersion> This way you'll get the Roslyn analyzers that warn about Android APIs. |
UPDATE I got net 8 maui update to compile, I have the following settings and it compiled ( not sure if it will work or if this is correct for MAUI 8): ![]() ![]() ![]() |
@plppp2001 I would change |
This worked, thank you. Net 8 is going... |
Worked for me too, thanks! |
Same issue but I don't want the app targeted at API 34 so I'm keeping the < used-sdk >. Also I'm getting an other warning during the build: |
Check manifest |
You can just remove the element completely in .NET 6+. It can get those values from your .csproj instead. in the ANDROIDMANIFEST.XML FILE |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
Fixes: dotnet#8331 Building a `net8.0-android33` project, currently fails with: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Emit the new `XA1038` warning message. This allows these projects to build with a reasonable warning message. The only concern down the road: if we ever support `net8.0-android35` alongside `net8.0-android34`, then we'd need to slightly adjust the logic here.
@AlexNik4 they've already fixed this in the next 17.9 Preview. Thanks, though! Private repo, but the change is here: https://github.com/xamarin/XamarinVS/pull/14329 |
Does Also,
|
@aqua-ix I believe the answer is "yes" to all your questions. However, I would usually completely omit |
Fixes: dotnet#8331 Building a `net8.0-android33` project, currently fails with: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Emit the new `XA1038` error message. This allows these projects to build with a reasonable error message. The only concern down the road: if we ever support `net8.0-android35` alongside `net8.0-android34`, then we'd need to slightly adjust the logic here.
Fixes: dotnet#8331 Building a `net8.0-android33` project, currently fails with: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Emit the new `XA1038` error message. This allows these projects to build with a reasonable error message. The only concern down the road: if we ever support `net8.0-android35` alongside `net8.0-android34`, then we'd need to slightly adjust the logic here.
Fixes: dotnet#8331 Building a `net8.0-android33` project, currently fails with: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Emit the new `XA1038` error message. This allows these projects to build with a reasonable error message. The only concern down the road: if we ever support `net8.0-android35` alongside `net8.0-android34`, then we'd need to slightly adjust the logic here.
Hi @jonathanpeppers
Is the TargetFrameworkVersion API 34 in .Net 8? Is this the same as "Compile using android framework" in XF? In MAUI i can set "Target Android Framework" under the Application / Android targets tab. Is this the targetSdkVersion value for the manifest file? Thank you |
Can you share an example of what your I would recommend what the project templates do:
The various project options pages & manifest editor might simply be outdated. We can file something with IDE teams to look into this. And if you want to do something else, maybe what are you trying to do? |
Why can't you just remove We have this documented here: https://learn.microsoft.com/en-us/dotnet/maui/migration/android-projects?view=net-maui-8.0#changes-to-androidmanifestxml |
I have removed <?xml version="1.0" encoding="utf-8"?>
<manifest android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:fullBackupContent="@xml/backup_rules" android:dataExtractionRules="@xml/backup_rules_api31" android:localeConfig="@xml/locales_config" android:supportsRtl="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/PushNotificationAndroid" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest> At compile time Maui generates this <uses-sdk android:minSdkVersion="24" /> The |
I removed that, works like a charm. Net8 Maui.
www.PaulAstramowicz.com
…________________________________
From: Jonathan Peppers ***@***.***>
Sent: Wednesday, January 10, 2024 6:54:48 PM
To: xamarin/xamarin-android ***@***.***>
Cc: Paul Astro ***@***.***>; Mention ***@***.***>
Subject: Re: [xamarin/xamarin-android] `TargetFramework=net8.0-android33` gives poor error message (Issue #8331)
Why can't you just remove <uses-sdk/> everywhere?
We have this documented here: https://learn.microsoft.com/en-us/dotnet/maui/migration/android-projects?view=net-maui-8.0#changes-to-androidmanifestxml
—
Reply to this email directly, view it on GitHub<#8331 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AK2EVSWPWPEGDYRHA4TEDEDYN3IWRAVCNFSM6AAAAAA4WXNV3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGM2DKMBRHE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@AlleSchonWeg how are you looking at the
|
No. I just open it with notepad++. The one located in the |
Yes, that is not the final one. Are you wanting to the the value to something other than the default? Is something not working? |
Ah ok. I thought this was the final one.
Now i understand how this works. Thank you |
The |
I tested a bit more. The warning i mentioned earlier:
happens when the targetSdkVersion is set to 28 from maui. Maui set 28 in the apk if in the platforms/android/AndroidManifest.xml file is an empty <?xml version="1.0" encoding="utf-8"?>
<manifest android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:fullBackupContent="@xml/backup_rules" android:dataExtractionRules="@xml/backup_rules_api31" android:localeConfig="@xml/locales_config" android:supportsRtl="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/PushNotificationAndroid" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-sdk />
</manifest> Completely remove the empty node generated value 34. |
I am running into this issue. The error message (from the original post) is below, and is completely unhelpful because it does not tell me what to do, in order to fix the error. I don't know what a workload manifest is or how to add anything to it. Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests I am in the process of upgrading our widespread and popular app from Xamarin to net8.0-android. I understand that by default, .net 8 sets the target OS version to 34. However, since our app hasn't yet been proved compatible with the Android OS changes that take effect when apps say they target version 34, I wish to leave this as 33 for the time being. However, I cannot build with it set to 33, I receive the error above. I can leave the property property set to 34 but include in the manifest file. It's not clear whether this works or not (from the perspective of Android then considering our app to be targetting OS 33) but that then generates its own compiler warning: Warning XA4211 AndroidManifest.xml //uses-sdk/@android:targetSdkVersion '33' is less than $(TargetFrameworkVersion) ''. Using API-34 for ACW compilation. In short, our project needs to be built using the latest tools, specify a minimum Android version of 21, and a target Android version of 33, and have no errors or warnings during a build. |
@divil5000 as a workaround you can still target net7 and use this in your csproj : |
I could, but then presumably miss out on all that .net 8 has to offer. Is this actually an acknowledged bug then? Did Microsoft simply not realise that people would wish to compile using the latest SDKs but that OS targeting is different? I keep hoping that I've simply misunderstood something. |
So for Android if you use the I think what you actually want is to add the following to your <uses-sdk android:targetSdkVersion="33" /> In .net 6/7/8+ the MSBuild property adding the API level to the end of So to sum up.
If you want to compiled against API 34 but target API 33 you will get the following warning.
in an ideal world these should match, this is something google recommends. This is why this warning exists. If you do not want to see this you might be able to disable the warning via the <NoWarn>XA1006;XA4211</NoWarn> I'm pretty sure @jonathanpeppers or @jonpryor will correct me if I'm wrong on any of this. |
Thanks Dean for that comprehensive explanation. I am glad my understanding was approaching what you said. As regards your last paragraph, Google is clearly pretending it lives in an ideal world, whereas most of us do not. There shouldn't be a warning for developers who haven't managed to go through the whole develop/test process of targeting the next API version yet. Updating one's build tools (as I am currently in the process of doing) is a different job to re-targeting one's app to the next OS version. It sounds like I'm ok at the moment with my entry to explicitly target API 33 while building against API 34. I just object to the warning :) |
Thanks for the explanation as it was not this clear in the documentation @dellis1972 |
|
…API levels Fixes: dotnet#8331 Context: dotnet#8569 Context: dotnet/sdk@25b360d Building for `net9.0-android33` would give a poor error message: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Opt into `%(DefineConstantsOnly)=true` for API levels 21-33 (and not the latest), which allows the .NET SDK to emit the *better* .NET SDK error message instead. So now users will get: (_CheckForInvalidTargetPlatformVersion target) -> dotnet/sdk/9.0.100-alpha.1.23628.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(243,5): error NETSDK1140: 33.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 34.0 I added a test for this scenario.
…API levels (#8777) Fixes: #8331 Context: #8569 Context: dotnet/sdk@25b360d Building for `net9.0-android33` would give a poor error message: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Opt into `%(DefineConstantsOnly)=true` for API levels 21-33 (and not the latest), which allows the .NET SDK to emit the *better* .NET SDK error message instead. So now users will get: (_CheckForInvalidTargetPlatformVersion target) -> dotnet/sdk/9.0.100-alpha.1.23628.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(243,5): error NETSDK1140: 33.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 34.0 I added a test for this scenario.
…API levels (#8777) Fixes: #8331 Context: #8569 Context: dotnet/sdk@25b360d Building for `net9.0-android33` would give a poor error message: error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets To solve this, you would either change 33 to 34, or just remove the number to rely on the default value. To make this easier: * Automatically switch to 34 if the user specifies 33 or less. * Opt into `%(DefineConstantsOnly)=true` for API levels 21-33 (and not the latest), which allows the .NET SDK to emit the *better* .NET SDK error message instead. So now users will get: (_CheckForInvalidTargetPlatformVersion target) -> dotnet/sdk/9.0.100-alpha.1.23628.5/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(243,5): error NETSDK1140: 33.0 is not a valid TargetPlatformVersion for Android. Valid versions include: 34.0 I added a test for this scenario.
Android application type
.NET Android (net8.0-android, etc.)
Affected platform version
.NET 8
Description
.NET 8 is API 34, so 33 is invalid, but you get a poor error message:
https://discord.com/channels/732297728826277939/732297916680765551/1151549736269119549
It would be nice if we could emit a better message here, so see what the .NET SDK expects us to do.
Steps to Reproduce
dotnet new android
TargetFramework
Did you find any workaround?
Remove
33.0
Relevant log output
No response
The text was updated successfully, but these errors were encountered: