更新软件包后,Android资源错误

时间:2018-09-05 18:18:53

标签: c# android xamarin sdk

我的任务是在Xamarin.Forms应用程序中更新所有第三方的依赖关系。这些文件可以追溯到一年前以各种版本保留。我对Xamarin.Forms有点陌生,并且对iOS开发比对Android开发更加熟悉。

此更新包括从Xamarin.Forms 2.5到3.1的更改。 iOS版本运行良好,但是在Android项目中,我看到了12个缺少的资源错误,这些错误似乎都与通知有关(我已经摘掉了文件路径的开头):

.../obj/Debug/lp/34/jl/res/values/values.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Info'.
.../obj/Debug/lp/34/jl/res/values-v21/values-v21.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Info'.
.../obj/Debug/lp/34/jl/res/values-v24/values-v24.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Info'.
.../obj/Debug/lp/34/jl/res/values/values.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification'.
.../obj/Debug/lp/34/jl/res/values-v21/values-v21.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification'.
.../Debug/lp/34/jl/res/values-v24/values-v24.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification'.
.../Debug/lp/34/jl/res/values/values.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Time'.
.../obj/Debug/lp/34/jl/res/values-v21/values-v21.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Time'.
.../obj/Debug/lp/34/jl/res/values-v24/values-v24.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Time'.
.../obj/Debug/lp/34/jl/res/values/values.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Title'.
.../obj/Debug/lp/34/jl/res/values-v21/values-v21.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Title'.
.../obj/Debug/lp/34/jl/res/values-v24/values-v24.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.Compat.Notification.Title'.

到目前为止,从我的研究看来,这种错误可能是由于无意中针对多个版本的Android SDK或使用了错误的工具版本(请参阅:Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23)引起的。我已经将所有Xamarin.Android.Support。*库都更新为最新版本:

<Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable">
  <HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Annotations">
  <HintPath>..\packages\BiInc.Mobile.Framework.4.5.1.0\lib\monoandroid80\Xamarin.Android.Support.Annotations.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Compat">
  <HintPath>..\packages\BiInc.Mobile.Framework.4.5.1.0\lib\monoandroid80\Xamarin.Android.Support.Compat.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Core.UI">
  <HintPath>..\packages\Xamarin.Android.Support.Core.UI.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Core.Utils">
  <HintPath>..\packages\BiInc.Mobile.Framework.4.5.1.0\lib\monoandroid80\Xamarin.Android.Support.Core.Utils.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.CustomTabs">
  <HintPath>..\packages\Xamarin.Android.Support.CustomTabs.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.CustomTabs.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Design">
  <HintPath>..\packages\Xamarin.Android.Support.Design.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Fragment">
  <HintPath>..\packages\Xamarin.Android.Support.Fragment.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Media.Compat">
  <HintPath>..\packages\Xamarin.Android.Support.Media.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.Transition">
  <HintPath>..\packages\Xamarin.Android.Support.Transition.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v4">
  <HintPath>..\packages\Xamarin.Android.Support.v4.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v4.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.AppCompat">
  <HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.CardView">
  <HintPath>..\packages\Xamarin.Android.Support.v7.CardView.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.CardView.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.MediaRouter">
  <HintPath>..\packages\Xamarin.Android.Support.v7.MediaRouter.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.Palette">
  <HintPath>..\packages\Xamarin.Android.Support.v7.Palette.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.Palette.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.RecyclerView">
  <HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v8.RenderScript, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Xamarin.Android.Support.v8.RenderScript.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v8.RenderScript.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Android.Support.Vector.Drawable">
  <HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll</HintPath>
  <Private>True</Private>
</Reference>

在我的AndroidManifest.xml中,我有:

<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28" />

我知道这不是我的计算机特有的构建环境问题,因为我们正在使用Microsoft的AppCenter服务,并且可以在其系统上重现这些完全相同的构建错误。

我正在考虑将支持库回滚到较早的版本,但是我不确定这是否有帮助或回滚到哪个版本。

我注意到,它抱怨的资源仅在自动生成的Resource.Designer.cs文件中被引用。例如:

public const int TextAppearance_Compat_Notification_Info = 2131493267;
public const int TextAppearance_Compat_Notification_Info_Media = 2131493231;

我不确定这样做的重要性,但是为了以防万一,我将其包括在内。

在另一篇文章中,我发现了一个可能相关的问题:Error:resource style/TextAppearance.Compat.Notification.Info (aka {packageId}.test:style/TextAppearance.Compat.Notification.Info) not found

但是将目标SDK版本设置为26并不能解决我的问题,因此我猜测这里还有其他问题。

如果有问题,我正在使用Visual Studio Enterprise for Mac 7.6.3。

为了重现此问题,我尝试构建一个示例项目,但到目前为止还无法完成。

具体来说,我想知道在尝试将Xamarin.Forms项目从较早的版本(例如2.5)升级到3.1版时是否有人遇到了这些同样的资源丢失错误。也许我缺少明显的东西?

---更新:如下面的SushiHangover所建议,我已经对该项目进行了完全依赖项审核。我有:

  1. 从所有子项目中删除了所有依赖项
  2. 添加了我希望更新为Xamarin.Forms的版本(当前版本为3.1.0.697729)
  3. 小心地将每个必需的软件包重新添加到需要它们的子项目中。如下所述,我能够摆脱许多明显未使用的依赖项。这使Android支持库的版本为26.0.2,比当前版本落后几个版本。
  4. 已确认我是根据最新的android SDK构建的。

我又回到了与以前相同的12个构建错误。我不确定从这里去哪里。一路上,我创建了一系列git分支作为可能的还原点。接下来,我将尝试以其他顺序添加一些软件包,以防影响某些事情。

0 个答案:

没有答案