Why Epoxy does not generate model class?
Asked Answered
G

2

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
  }

}
Glorygloryofthesnow answered 21/7, 2018 at 16:50 Comment(4)
Did you add apply plugin: 'kotlin-kapt'?Redneck
Yes, I have this lineGlorygloryofthesnow
how did u declare dependencies ?Bullins
Did you solve this issue? I'm also facing this same issue now.- @GlorygloryofthesnowHolocaust
M
9

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

Maurits answered 20/3, 2020 at 10:7 Comment(0)
D
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.

Delve answered 7/1, 2022 at 0:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.