Xamarin.Forms 5.0.0.2612 破坏 Android 版本:错误 APT2260:找不到资源样式/Theme.AppCompat.Light.Dialog

问题描述 投票:0回答:1

更新到 Xamarin.Forms v5.0.0.2612 后,我的 Xamarin.Android 应用程序构建失败,并出现以下编译器错误:

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]

我从 Xamarin.Forms v5.0.0.2612 进行更新,并且没有对我的代码进行任何更改(在 Xamarin.Forms v5.0.0.2612 上成功编译),因此不应有任何重大更改。此版本的 Xamarin.Forms 是否有问题?

xamarin xamarin.forms xamarin.android
1个回答
0
投票

说明

在 Xamarin.Forms v5.0.0 Service Release 15 的发行说明中,他们提到它现在针对的是 Android 33:

目标 MonoAndroid13.0 by @jfversluis in

#15718

解决方案

这意味着要使用 Xamarin.Forms,您现在需要在 Xamarin.Android 应用程序中针对 Android API 33,并且我们必须更新两个文件才能解决此问题:

Xamarin.Android CSPROJ

在 Anrdoid 应用程序的

csproj

 文件(通常名为 
*.Droid.csproj
*.Android.csproj
)中,将 
<TargetFrameworkVersion>
 更新为 
v13.0

<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>
AndroidManifest.xml

AndroidManifest.xml

(又名 Android 清单)中,将 
android:targetSdkVersion
 更新为 
"33"

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" />
    
© www.soinside.com 2019 - 2024. All rights reserved.