Types from Xamarin.AndroidX.AppCompat.Resource not mapped correctly for preview03 packages
See original GitHub issueAfter upgrading to the preview03 versions of the support packages builds started failing for my Xamarin Forms Android project with the following error message:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2105,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2105,5): error MSB4018: Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper' (defined in assembly 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper
The linker seems to be looking for the DrawableWrapper definition in the Xamarin.AndroidX.AppCompat assembly, which is where it was defined prior to the preview03 release of the support package. It seems this type along with a few others were moved into a new Android library, androidx.appcompat.appcompat-resources, so they are now located in a new assembly for the Xamarin Android support packages, Xamarin.AndroidX.AppCompat.Resources.
I was able to get the build working by adding a _AndroidXAssembly definition for Xamarin.Android.AppCompat.Resources in Xamarin.AndroidX.Migration.props, and also updating the AndroidX .NET Assembly column values to Xamarin.AndroidX.AppCompat.Resources in androidx-mapping.csv for the types:
AndroidX.AppCompat.Graphics.Drawable.AnimatedStateListDrawableCompat
AndroidX.AppCompat.Graphics.Drawable.DrawableWrapper
AndroidX.AppCompat.Content.Res.AppCompatResources
AndroidX.AppCompat.Widget.DrawableUtils
AndroidX.AppCompat.Widget.TintContextWrapper
AndroidX.AppCompat.Widget.VectorEnabledTintResources
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:31 (13 by maintainers)
We are looking into this right now, thanks for your patience 😃
@Pitchaiyan
Sure. But we need to reproduce the issue first (in order to fix it).
Downloaded it and testing.