Ran into an issue with butterknife and kotlin 1.3 ...
# android
n
Ran into an issue with butterknife and kotlin 1.3 (though the example is kinda silly). Stripped down to the bare minimum here is the setup Simple android project with on app and one library module using butterknife. The library module has the following class
Copy code
class Foo {
    @BindView(R2.id.someText) @JvmField var someText: TextView? = null

    fun bind(activity: Activity) {
        ButterKnife.bind(this, activity)
        requireNotNull(someText)
    }
}
The app module has a single activity with the following onCreate
Copy code
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    Foo().bind(this)
}
When running this “app” it will crash with an `IllegalArgumentException`as the
someText
field is going to be null. The generated
Foo_ViewBinding
uses the following piece of code to bind
someText
target.someText = Utils.findOptionalViewAsType(source, 2131492945, "field 'someText'", TextView.class);
2131492945 is the value of
R.id.someText