Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvvmcross binding on switch fails on release

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

like image 695
Roubachof Avatar asked Feb 02 '14 00:02

Roubachof


1 Answers

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 = [email protected];
}
like image 58
Kiliman Avatar answered Oct 06 '22 01:10

Kiliman