You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran dotnet build in the terminal so I could add the -bl parameter, and the build succeeded. Apparently triggering a restore, or a build, from within VS for Mac isn't working and is "stuck" on version 33.0, but running dotnet build from terminal succeeds.
Here's the error I was getting in VS in case it helps someone else:
/usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. /usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. /usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests.
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.
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.
Now i understand how this works.
One last question: Is it possible to view the final AndroidManifest.xml somewhere in the obj or bin forders? Just to verify if all my settings correctly merged.
The .apk is the source of truth. You might try the apkanalyzer tool from the Android SDK's cmdline-tools. Checkout the View information in the manifest section:
I tested a bit more. The warning i mentioned earlier:
XA1006: The TargetFrameworkVersion (Android API level 34) is higher than the targetSdkVersion (28). Please increase the android:targetSdkVersion in the AndroidManifest.xml so that the API levels match.
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 <uses-sdk/> node. Like this:
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.
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 TargetFramework that is controlling what your app is Compiled against.
I think what you actually want is to add the following to your AndroidManifest.xml
<uses-sdkandroid:targetSdkVersion="33" />
In .net 6/7/8+ the MSBuild property SupportedOSPlatformVersion controls the android:minSdkVersion. TargetFramework(s) will control BOTH android:targetSdkVersion and android:compileSdkVersion unless android:targetSdkVersion is provided in the AndroidManifest.xml already.
adding the API level to the end of net8.0-android (e.g net8.0-android33.0) will mean you compile aginst that API level. I think the plan is as we move forward we will only support compiling against the latest API level as we do the .net SDK (@jonpryor correct me if I'm wrong here). So .net 8 will only allow compiling against API 34, .net 7 API 33, .net 9 API 34 or 35 depending on when the next stable API level is released by google.
So to sum up.
minSdkVersion is the minimum platform you support. compileSdkVersion is what your compiled agsinst. targetSdkVersion is what your API Level app Supports, this can be different from compileSdkVersion since you can use runtime checks to see which API level you are on.
If you want to compiled against API 34 but target API 33 you will get the following warning.
warning XA1006: The TargetFrameworkVersion (Android API level 34) is higher than the targetSdkVersion (33). Please increase the android:targetSdkVersionin theAndroidManifest.xml so that the API levels match.
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/> MSbuild element
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 :)
Activity
kpespisa commentedon Nov 8, 2023
I'm seeing this error even if I remove
33.0from the target framework of an Android Java Library Binding project<TargetFramework>net8.0-android</TargetFramework>Can you provide any more details on why this error occurs? This is with RC2
jonathanpeppers commentedon Nov 8, 2023
Can you share a
.binlogof the build? https://aka.ms/binlogkpespisa commentedon Nov 8, 2023
Thank you! Your suggestion lead to a solution :)
I ran
dotnet buildin the terminal so I could add the-blparameter, and the build succeeded. Apparently triggering a restore, or a build, from within VS for Mac isn't working and is "stuck" on version 33.0, but runningdotnet buildfrom terminal succeeds.Here's the error I was getting in VS in case it helps someone else:
/usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. /usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests. /usr/local/share/dotnet/sdk/8.0.100-rc.2.23502.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5) : error NETSDK1181: Error getting pack version: Pack 'Microsoft.Android.Ref.33' was not present in workload manifests.jonathanpeppers commentedon Nov 8, 2023
VS Mac has a checkbox that allows it to use the .NET 8 SDK. Maybe it is confused and mixing .NET 7 and 8?
kpespisa commentedon Nov 8, 2023
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.
ziomek64 commentedon Nov 14, 2023
Hello, I'm also getting this error. When upgrading maui from .net 7 to .net 8. I tried your solutions.. Anything I can try?
wallym commentedon Nov 14, 2023
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.
30 remaining items
AlleSchonWeg commentedon Jan 10, 2024
Ah ok. I thought this was the final one.
aapt2shows the the correcttargetSdkVersionNow i understand how this works.
One last question: Is it possible to view the final
AndroidManifest.xmlsomewhere in the obj or bin forders? Just to verify if all my settings correctly merged.Thank you
jonathanpeppers commentedon Jan 10, 2024
The
.apkis the source of truth. You might try theapkanalyzertool from the Android SDK's cmdline-tools. Checkout theView information in the manifestsection:AlleSchonWeg commentedon Jan 11, 2024
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
<uses-sdk/>node. Like this:Completely remove the empty node generated value 34.
divil5000 commentedon Jan 30, 2024
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.
jonathanantoine commentedon Jan 30, 2024
@divil5000 as a workaround you can still target net7 and use this in your csproj :
<TargetFrameworks>net7.0-android33.0</TargetFrameworks>divil5000 commentedon Jan 31, 2024
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.
dellis1972 commentedon Jan 31, 2024
So for Android if you use the
TargetFrameworkthat is controlling what your app is Compiled against.I think what you actually want is to add the following to your
AndroidManifest.xmlIn .net 6/7/8+ the MSBuild property
SupportedOSPlatformVersioncontrols theandroid:minSdkVersion.TargetFramework(s)will control BOTHandroid:targetSdkVersionandandroid:compileSdkVersionunlessandroid:targetSdkVersionis provided in the AndroidManifest.xml already.adding the API level to the end of
net8.0-android(e.gnet8.0-android33.0) will mean you compile aginst that API level. I think the plan is as we move forward we will only support compiling against the latest API level as we do the .net SDK (@jonpryor correct me if I'm wrong here). So .net 8 will only allow compiling against API 34, .net 7 API 33, .net 9 API 34 or 35 depending on when the next stable API level is released by google.So to sum up.
minSdkVersionis the minimum platform you support.compileSdkVersionis what your compiled agsinst.targetSdkVersionis what your API Level app Supports, this can be different fromcompileSdkVersionsince you can use runtime checks to see which API level you are on.If you want to compiled against API 34 but target API 33 you will get the following warning.
warning XA1006: The TargetFrameworkVersion (Android API level 34) is higher than the targetSdkVersion (33). Please increase theandroid:targetSdkVersionin theAndroidManifest.xmlso that the API levels match.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/>MSbuild elementI'm pretty sure @jonathanpeppers or @jonpryor will correct me if I'm wrong on any of this.
divil5000 commentedon Jan 31, 2024
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 :)
jonathanantoine commentedon Jan 31, 2024
Thanks for the explanation as it was not this clear in the documentation @dellis1972
crwsolutions commentedon Feb 28, 2024
<uses-sdk/>keeps being added by Visual studio's (Version 17.9.0) new dedicated manifest editor (if you touch and save some other value).[Xamarin.Android.Build.Tasks] set `%(DefineConstantsOnly)` for older …
[Xamarin.Android.Build.Tasks] set `%(DefineConstantsOnly)` for older …
[Xamarin.Android.Build.Tasks] set `%(DefineConstantsOnly)` for older …