mvvmcross binding on switch fails on release

一个人想着一个人 提交于 2019-12-30 08:28:29

问题


I have a weird bug in my MVVMCross app.

Considering the following scenario:

<Switch
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"
    android:clickable="false"
    android:layout_alignParentRight="true"
    android:id="@+id/activatedSwitch"
    local:MvxBind="Checked IsActive" />
  • Compile version: level 14
  • Minimum version: level 14
  • Target version: level 14

  • Linking: Sdk Assemblies Only

  • Android Phone version is 4.1.2.

When I run the app in Debug mode, all is ok.

But when I run it in Release, the binding to the Checked property failed with the following error:

E/MvxBind (11670): 12,70 View type not found - Switch


回答1:


Since MvvmCross uses reflection to perform databinding, the linker is not seeing the Checked property and is not including it in your binary. There is a file name LinkerPleaseInclude.cs that you can edit to add a reference to this property.

Something like:

public void Include(Switch @switch)
{
    @switch.CheckedChange += (sender, args) => @switch.Checked = !@switch.Checked;
}


来源:https://stackoverflow.com/questions/21505349/mvvmcross-binding-on-switch-fails-on-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!