airbnb / epoxy

Epoxy is an Android library for building complex screens in a RecyclerView
https://goo.gl/eIK82p
Apache License 2.0
8.51k stars 728 forks source link

error: incompatible types: <null> cannot be converted to int @com.airbnb.epoxy.EpoxyModelClass(layout = null) #1345

Closed ColtonIdle closed 1 year ago

ColtonIdle commented 1 year ago

updated to AGP 8.0 and I'm hit with this error. I'm assuming im doing something wrong.

If I go to the actual class (the nongenerated version) I get a different error

@EpoxyModelClass(layout = R.layout.mylayout)

"An annotation argument must be a compile-time constant"

been using epoxy for years and first time i hit this

elihart commented 1 year ago

See https://developer.android.com/build/releases/gradle-plugin#default-changes

AGP 8.0 starts to enable nonFinalResIds by default. Annotations require constant values, so non final values cannot be used as annotation arguments.

This has long been an issue with library projects, and a workaround exists to support non final R values https://github.com/airbnb/epoxy#library-projects

ColtonIdle commented 1 year ago

thanks. im not sure if im misunderstanding. my project isn't a library project? should i be using something else entirely? 😓

elihart commented 1 year ago

this used to apply to only library projects. as of AGP 8.0 it now applies to application modules as well. you could use the butterknife and R2 approach, or probably simplest is to just disable nonFinalResIds in agp

ColtonIdle commented 1 year ago

will disable for now. thanks eli

ciwhiz commented 4 months ago

AGP : 8.4 epoxy : 5.1.1 Android targetSDK 34 Is there any other way other than disabling nonFinalResIds? I am currently using ButterKnife and epoxy in parallel. If you disable the nonFinalResIds option, an error will occur in ButterKnife. Since it is difficult to fix ButterKnife right now, I would like to solve this issue in another way.