MvvmCross - 尝试使用碎片和最新支持的lib导致连接问题 [英] MvvmCross - trying to use Fragments AND latest support lib results in linking problems
问题描述
我想用SlidingPaneLayout或DrawerLayout,但这些都需要一个较新的支持库。 Xamarin有一个在组件商店(Android支持库V4(启18)。
I'd like to use the SlidingPaneLayout or DrawerLayout, but these require a newer support library. Xamarin has one in the component store (Android Support Library v4 (Rev 18).
但是,如果我尝试使用此,并使用MVVM碎片支持(这需要Mono.Android.Support.v4参考)我得到这样的链接错误:
But if I try to use this AND use the Mvvm Fragments support (which requires a reference to Mono.Android.Support.v4) I get linker errors like this:
error : Duplicate managed type found! Mappings between managed types and Java types must be unique. First Type: 'Android.Support.V4.App.FragmentManager/IOnBackStackChangedListenerImplementor, Xamarin.Android.Support.v4-r18, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'; Second Type: 'Android.Support.V4.App.FragmentManager/IOnBackStackChangedListenerImplementor, Mono.Android.Support.v4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
删除旧的支持库参考结果在不同的连接错误;
Removing the old support library reference results in a different linker error;
错误CS0012: Android.Support.V4.App.FragmentActivity'在未引用的程序集定义的类型。考虑添加到程序集的引用
Mono.Android.Support.v4,版本= 0.0.0.0,文化=中性公钥= 84e04ff9cfb79065
error CS0012: The type Android.Support.V4.App.FragmentActivity' is defined in an assembly that is not referenced. Consider adding a reference to assembly
Mono.Android.Support.v4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
推荐答案
我相信这是从单声道到Xamarin。更名的组装造成Xamarin的一个普遍问题。
I believe this is a general problem caused by Xamarin rebranding an assembly from 'Mono' to 'Xamarin'.
像MvvmCross第三方组件及其他类似的谷歌Play服务的组件链接目前对Mono'命名组件,其附带Xamarin.Android(前身为单声道Android设备)。
Third party assemblies like MvvmCross and others like the Google Play services component currently link against the 'Mono'-named assembly which ships with Xamarin.Android (formerly Mono for Android).
目前,MvvmCross不能改变它链接到Xamarin命名的程序没有通过谷歌播放组件消除对地图V2支持 - 我们有更多的用户目前要求苛刻的地图那么苛刻在抽屉式导航支持支持最新的支持库。
Currently, MvvmCross can't change it's linking to the 'Xamarin' named assembly without removing support for Maps v2 via the Google Play component - and we have more users currently demanding support for maps then demanding support for the navigation drawer in the latest support library.
如果任何人都需要对Xamarin'命名程序集链接,那么你需要一些方法来重定向组件改变名称的工作。办法我知道这样做是:
If anyone needs to link against the 'Xamarin'-named assembly, then you need some way to redirect assemblies to work with the changed name. Ways I know of doing this are:
- 在完整的.NET我相信你能做到在app.config文件这个使用'绑定重定向',但我不认为这些都可以在Xamarin.Android。
- <击>你可能不是能够使用一个虚拟的'Mono.Android.Support.v4组件,该组件只包含的类型
[TypeForwardedTo]
的声明做重定向 - 产生这将是有点乏味,但应该工作罢>我试图生成一个TypeForwardTo
组装 - 的 https://gist.github.com/slodge/6790040 - 但我认为,Xamarin已经用事实组装强命名意味着我不能得到这个工作:?/ Xamarin也许能虽然 - 您可以叉子和改造现有的MvvmCrossFragging'组装 - 这不是大 - 因此它引用Xamarin'命名部件。您还需要为你需要的任何其他组件做到这一点 - 例如谷歌在玩一个地图。
- In full .Net I believe you can do this using 'binding redirects' in an app.config file, but I don't think these are available in Xamarin.Android.
You might instead be able to do the redirects using a dummy 'Mono.Android.Support.v4' assembly which contains onlyI tried to generate a[TypeForwardedTo]
declarations of types - generating this would be a bit tedious but should work.TypeForwardTo
assembly - https://gist.github.com/slodge/6790040 - but I think the fact that Xamarin have used assembly strong naming means I can't get this to work :/ Xamarin might be able to though?- You could fork and rebuild the existing MvvmCross 'Fragging' assembly - it's not large - so that it references the 'Xamarin'-named component. You would also need to do this for any other assemblies you need - e.g. the Google Play one for maps.
这篇关于MvvmCross - 尝试使用碎片和最新支持的lib导致连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!