Butterknife: Don't work in kotlin

Created on 16 Aug 2017  Â·  10Comments  Â·  Source: JakeWharton/butterknife

I added the @JvmField annotation to the view, but it is still null after ButterKnife.bind(this).

Most helpful comment

@hippyk That kind of defeats the purpose of this library as you now have to maintain the stuff yourself. Just use kapt, that's what it's meant for.

All 10 comments

@hippyk there's a kotlin implementation of Butterknife wirriten by Jake called kotterknife.

Please, check it out.

There's not enough information to make this report actionable. If you're having a problem the easiest way to get it resolved is by creating a standalone sample that demonstrates it in isolation. Otherwise it's impossible to know what you're doing.

@piotrek1543 Thank u! But My situation is special. There are too many codes to change if I use kotterknife instead.

@JakeWharton I found the "_ViewBinding" class for the kt class was not generated.

Are you using kapt?

On Wed, Aug 16, 2017 at 5:38 PM hippyk notifications@github.com wrote:

@JakeWharton https://github.com/jakewharton I found the "_ViewBinding"
class for the kt class was not generated.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1058#issuecomment-322937030,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEUvoDqZJoKUJmpnwWICuLBq1R6e2ks5sY4uZgaJpZM4O4_xp
.

@JakeWharton No, but I'm using “kotlin-android-extensions”

Without kapt Butter Knife will not work with Kotlin.

On Wed, Aug 16, 2017 at 6:27 PM hippyk notifications@github.com wrote:

@JakeWharton https://github.com/jakewharton No, but I'm using
“kotlin-android-extensions”

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1058#issuecomment-322943550,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEWMdCk2yQVqgF3n5fcDernzL-L67ks5sY5cQgaJpZM4O4_xp
.

@JakeWharton Thank you very much

I found another solution. Before converting the java file to kt, copy the method “xxxActivity_ViewBinding” that is generated and then add it to the kt file directly.

@hippyk That kind of defeats the purpose of this library as you now have to maintain the stuff yourself. Just use kapt, that's what it's meant for.

Was this page helpful?
0 / 5 - 0 ratings