Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Forms 5.0.0.2612 Breaks Android Build: Error APT2260: resource style/Theme.AppCompat.Light.Dialog not found

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?

like image 573
Brandon Minnick Avatar asked Sep 08 '25 17:09

Brandon Minnick


1 Answers

Explanation

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

Solution

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:

1. Xamarin.Android CSPROJ

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>

2. AndroidManifest.xml

In AndroidManifest.xml (aka The Android Manifest), update android:targetSdkVersion to "33":

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
like image 192
Brandon Minnick Avatar answered Sep 10 '25 06:09

Brandon Minnick