5

I want to use Epoxy for my recyclerView with kotlin, but Epoxy Model does not generate PostModel_() class, what wrong with it?

@EpoxyModelClass(layout = R.layout.iteam)
abstract class PostModel : EpoxyModelWithHolder<PostModel.PostHolder>() {
  @EpoxyAttribute
  lateinit var userName: String
  @EpoxyAttribute
  lateinit var avatarIcon: Drawable
  @EpoxyAttribute
  lateinit var post: Drawable

  override fun bind(holder: PostHolder) {
    holder.avatarIcon.setImageDrawable(avatarIcon)
    holder.post.setImageDrawable(post)
    holder.name.text = userName

  }

  class PostHolder : BaseEpoxyHolder() {
    @BindView(R.id.name)
    lateinit var name: TextView
    @BindView(R.id.ic_avatar)
    lateinit var avatarIcon: ImageView
    @BindView(R.id.post)
    lateinit var post: ImageView
  }

}
4
  • 2
    Did you add apply plugin: 'kotlin-kapt'? Jul 21, 2018 at 18:03
  • Yes, I have this line Jul 22, 2018 at 16:05
  • how did u declare dependencies ?
    – shakil.k
    Sep 2, 2018 at 8:27
  • Did you solve this issue? I'm also facing this same issue now.- @manwhotrycoding
    – sri
    Dec 11, 2019 at 7:03

2 Answers 2

8

One common mistake when using Epoxy in Kotlin is mixing annotation processing engines. If you copied this from Epoxy's readme:

dependencies {
  implementation 'com.airbnb.android:epoxy:3.x.y'
  // Add the annotation processor if you are using Epoxy's annotations (recommended)
  annotationProcessor 'com.airbnb.android:epoxy-processor:3.x.y'
}

You probably forgot to apply what they suggest for kotlin users few lines later in the same readme:

make sure to use kapt instead of annotationProcessor

0

I mistakenly deleted the first line from my model file:

package com.myCustomDomain.myapp.epoxyModel

so the auto generated files were generated with wrong filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.