I have a large Android project written in Java and am currently converting it to Kotlin. Many of my activites and fragments use databinding.
Initially, when I converted my first activity using databinding to Kotlin, the project was unable to build for this activity. The error said there were missing references to the databinding library. I added:
kapt 'com.android.databinding:compiler:2.0.0-beta6'
to dependencies in app/build.gradle and also
kapt {
generateStubs = true
}
to the same file.
After building, the Kotlin activity with databinding worked, whereas all the remaining Java databinding activites now report that the databinding package reference does not exist.
This leaves me in a tough spot. I was planning on converting the activities and fragments one by one to Kotlin and building them as I go, but this seems not doable at the moment since I have to make a choice between Java or Kotlin working at every build.
I found Kotterknife: https://github.com/JakeWharton/kotterknife , which is a view injection library for Kotlin, but I still cannot believe that there is no way to slowly convert your activities from Java to Kotlin, even if they do use databinding. It simply does not seem credible to me.
Has anyone done converted a project in such a way in the past and succeeded without having to make a choice one or the other? Is there a way to convert single activities as you go along? The other option is to just convert all the Java to Kotlin in one go and then make one single build after it's all done, but that seems a bit risky if you put in all the work and then realize you overlooked something. Any ideas? Thanks in advance.