After updating to Xamarin.Forms v5.0.0.2612, my Xamarin.Android app build fails with the following compiler error:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(156,3): error APT2260: resource style/Theme.AppCompat.Light.Dialog (aka com.minnick.HackerNews:style/Theme.AppCompat.Light.Dialog) not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(4): error APT2260: style attribute 'attr/colorAccent (aka com.minnick.HackerNews:attr/colorAccent)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(156,3): error APT2260: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.minnick.HackerNews:style/Theme.AppCompat.Light.DarkActionBar) not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowNoTitle (aka com.minnick.HackerNews:attr/windowNoTitle)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/windowActionBar (aka com.minnick.HackerNews:attr/windowActionBar)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimary (aka com.minnick.HackerNews:attr/colorPrimary)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(2): error APT2260: style attribute 'attr/colorPrimaryDark (aka com.minnick.HackerNews:attr/colorPrimaryDark)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(3): error APT2260: style attribute 'attr/colorAccent (aka com.minnick.HackerNews:attr/colorAccent)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
Resources\values\styles.xml(4): error APT2260: style attribute 'attr/windowActionModeOverlay (aka com.minnick.HackerNews:attr/windowActionModeOverlay)' not found. [D:\a\1\s\sample\HackerNews.Droid\HackerNews.Droid.csproj]
I am updating from Xamarin.Forms v5.0.0.2578, and I haven't made any changes to my code (which compiles successfully on Xamarin.Forms v5.0.0.2578), so there shouldn't be any breaking changes. Is there something broken in this release of Xamarin.Forms?
In the Release Notes for Xamarin.Forms v5.0.0 Service Release 15, they mention that it is now targeting Android v13, aka Android API 33:
Target MonoAndroid13.0 by @jfversluis in #15718
This means that to use Xamarin.Forms, you now need to be targeting Android API 33 in your Xamarin.Android app, and there are two files we must update to fix this:
In the csproj
file for your Anrdoid app (typically named *.Droid.csproj
or *.Android.csproj
), update the <TargetFrameworkVersion>
to v13.0
:
<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
In AndroidManifest.xml
(aka The Android Manifest), update android:targetSdkVersion
to "33"
:
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With