title: java.lang.RuntimeException: Failed to call observer method when starting Fragment with EditText (number) Two way databinding
body: <p>I'm trying to bind an <code>MutableLiveData&lt;Int&gt;</code> to an <code>EditText</code> element. I've already implemented the binding adapter but when I start the Activity I get an error: <code>java.lang.RuntimeException: Failed to call observer method</code></p>
  
  <p>Thanks for help.</p>
  
  <p><strong>Code:</strong> </p>
  
  <p><strong>ViewModel</strong></p>
  
  <p><code>val serverPort = MutableLiveData&lt;Int&gt;(9330)</code></p>
  
  <p><strong>XML</strong></p>
  
  <pre><code>    &lt;data&gt;
          &lt;variable
              name="vm"
              type="...LoginViewModel" /&gt;
      &lt;/data&gt;
      &lt;com.google.android.material.textfield.TextInputEditText
                          android:layout_width="match_parent"
                          android:layout_height="50dp"
                          android:layout_gravity="center"
                          android:inputType="number"
                          android:text="@={vm.serverPort}" /&gt;
  </code></pre>
  
  <p><strong>Adapter</strong></p>
  
  <pre><code>    object Converter {
  
  
      @BindingConversion
      @JvmStatic
      fun intToStr(value: Int?): String? {
          return value.toString()
      }
  
      @InverseBindingAdapter(attribute = "android:text")
      @JvmStatic
      fun captureIntValue(view: EditText?): Int? {
          var value: Long = 0
          try {
              value = view!!.text.toString().toInt().toLong()
          } catch (e: NumberFormatException) {
              e.printStackTrace()
          }
          return value.toInt()
      }
  </code></pre>