title: Android Data Binding Issue: The expression XXX cannot be inverted
body: <p>I'm a newbie for android data binding.
  I want to bind multiple SeekBars to a collection of float, such as</p>
  
  <pre><code>SeekBar1.progress &lt;---&gt; modelArray[0]
  SeekBar2.progress &lt;---&gt; modelArray[1]
  ...
  </code></pre>
  
  <p>Since the progress of SeekBar is a Int type, I think it would be better to use Converter, and below is the converter code:</p>
  
  <pre><code>import android.databinding.InverseMethod
  import android.util.Log
  import kotlin.math.roundToInt
  class Converter {
      @InverseMethod("progressToFloat")
      fun floatToProgress(value: Float): Int {
          val result = (value * 100.0f).roundToInt()
          Log.i("MODEL", "convert $value to $result(Int)")
          return result
      }
  
      fun progressToFloat(value: Int): Float {
          return value.toFloat()/100.0f
      }
  }
  </code></pre>
  
  <p>and the model structure looks like: </p>
  
  <pre><code>class Model {
   val params by lazy {
          ObservableArrayMap&lt;Int, Float&gt;()
   }
   //....
  }
  </code></pre>
  
  <p>and my xml is following:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
      &lt;data class="MyBinding"&gt;
          &lt;variable name="Converter" type="com.mypackage.model.Converter"&gt;&lt;/variable&gt;
          &lt;variable
              name="Converter"
              type="com.mypackage.model.Converter"&gt;&lt;/variable&gt;
  
          &lt;variable
              name="model"
              type="com.mypackage.model.Model"&gt;&lt;/variable&gt;
      &lt;/data&gt;
  ...
          &lt;SeekBar
              android:id="@+id/seekBar"
              android:layout_width="100dp"
              android:layout_height="30dp"
              android:layout_gravity="center"
              android:layout_marginTop="20dp"
              android:layout_marginBottom="20dp"
              android:progress="@={Converter.floatToProgress(model.params[0])}"/&gt;
  </code></pre>
  
  <p>The problem is, every time I build it, it shows :</p>
  
  <pre><code>Found data binding errors.
  ****/ data binding error ****
  msg:The expression converter.floatToProgress(modelParams0) cannot be inverted: 
  There is no inverse for method floatToProgress, you must add an @InverseMethod 
  annotation to the method to indicate which method should be used when using 
  it in two-way binding expressions
  </code></pre>
  
  <p>I already refer to lots of website, includes following:</p>
  
  <p><a href="https://medium.com/androiddevelopers/android-data-binding-inverse-functions-95aab4b11873" rel="nofollow noreferrer">https://medium.com/androiddevelopers/android-data-binding-inverse-functions-95aab4b11873</a></p>
  
  <p><a href="https://developer.android.com/topic/libraries/data-binding/two-way" rel="nofollow noreferrer">https://developer.android.com/topic/libraries/data-binding/two-way</a></p>
  
  <p>But I still cannot find out what problem is. Could anyone give me some suggestion?</p>
  
  <p>My development environment</p>
  
  <pre><code>macOS High Sierra, 
  Android Studio 3.2.1, with compileSdkVersion 28 and gradle 3.2.1
  </code></pre>
  
  <p><strong>Update:</strong> 
  I also try to write Converter as following :</p>
  
  <pre><code>object Converter { // change to object
      @InverseMethod("progressToFloat")
      @JvmStatic fun floatToProgress(value: Float): Int { // Add static
          val result = (value * 100.0f).roundToInt()
          Log.i("MODEL", "convert $value to $result(Int)")
          return result
      }
  
      @JvmStatic fun progressToFloat(value: Int): Float { // Add static
          return value.toFloat()/100.0f
      }
  }
  </code></pre>
  
  <p>It still does not work.</p>
  
  <p><strong>Solution</strong>
  Ok, I found the problem: My project does not use Kapt.
  After add it to build.gradle, all works fine.</p>
  
  <p><code>apply plugin: 'kotlin-kapt'</code></p>
  
  <p>Also, I update my converter body as following:</p>
  
  <pre><code>object Converter {
      @InverseMethod("progressToFloat")
      @JvmStatic fun floatToProgress(value: Float): Int {
          val result = (value * 100.0f).roundToInt()
          Log.i("MODEL", "convert $value to $result(Int)")
          return result
      }
  
      @JvmStatic fun progressToFloat(value: Int): Float {
          val result =  value.toFloat()/100.0f
          Log.i("MODEL", "convert $value to $result(Float)")
          return result
      }
  }
  </code></pre>
  
  <p>If the @JVMStatic removed, the project can compile successfully, but the binding does not work.</p>
  
  <p>Thanks everyone who give my suggestion. I think I just ask a silly question.</p>
  
  <p>Refer to:<a href="https://stackoverflow.com/questions/50137564/databinding-annotation-processor-kapt-warning">Databinding annotation processor kapt warning</a></p>