Butterknife: 8.8.1 Doesn't generate code with 'apt'

Created on 22 Aug 2017  Â·  6Comments  Â·  Source: JakeWharton/butterknife

Hello, I ran into an issue earlier where all of my views were null. I enabled debug and got the ButterKnife: MISS: Reached framework class. Abandoning search. log.

I found these related issues:

None of the suggested fixes like rebuilding/cleaning my project, caused Butterknife to generate files in the build/generated/source/apt folder. Just to clarify I did have everything correctly setup for apt to work in my Gradle build, so it wasn't that I just had that dependency set up wrong.

Because I'm already using Kotlin/kapt in my app I eventually "solved" my issue by just switching from:

compile "com.jakewharton:butterknife:8.8.1"
apt "com.jakewharton:butterknife-compiler:8.8.1"

to:

compile "com.jakewharton:butterknife:8.8.1"
kapt "com.jakewharton:butterknife-compiler:8.8.1"

I'm not sure the root cause of this issue, but I thought it'd be helpful to report. Hope this is helpful, thanks!

All 6 comments

Yes that is what using Kotlin requires. We should add it to the README.

I've been troubleshooting the same issue for a couple days now, where Butterknife isn't properly binding views since adding Kotlin to the project (even in Java activities). I had already tried the addition of kapt in addition to annotationProcessor for the butterknife-compiler dependency, but this didn't resolve the issue. It turns out that I also needed to run a gradle clean task to deal with cached versions of the generated files from Butterknife. This may be a useful detail to add to the READEME for users moving to Kotlin on existing Butterknife projects.

That would indicate broken incrementalism which is a build system problem
that should be reported, not a Butter Knife problem and it would happen
with any annotation processor that generates code.

On Thu, Sep 28, 2017 at 4:20 PM Harry Grillo notifications@github.com
wrote:

I've been troubleshooting the same issue for a couple days now, where
Butterknife isn't properly binding views since adding Kotlin to the project
(even in Java activities). I had already tried the addition of kapt in
addition to annotationProcessor for the butterknife-compiler dependency,
but this didn't resolve the issue. It turns out that I also needed to run a
gradle clean task to deal with cached versions of the generated files
from Butterknife. This may be a useful detail to add to the READEME for
users moving to Kotlin on existing Butterknife projects.

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/1062#issuecomment-332952530,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEETATOdUd-YqMSjXa79CAWhJ5MHhDks5sm_-VgaJpZM4O_HwL
.

Thanks man, you saved my day!

@redbassett Are you running a gradle clean everytime you change a Java/Kotlin code or you found a workaround for it?

So far, I have only needed to do it when adding the kapt dependency, but I haven't been working on that codebase much.

Was this page helpful?
0 / 5 - 0 ratings