Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with ViewBinding. #1388

Open
huanglongyu opened this issue May 25, 2023 · 1 comment
Open

Not compatible with ViewBinding. #1388

huanglongyu opened this issue May 25, 2023 · 1 comment

Comments

@huanglongyu
Copy link

huanglongyu commented May 25, 2023

here is my annotation

@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class Angle(val serialInterval: Int = 0)

and my activity

@Angle(serialInterval = 10)
class MainActivity : AppCompatActivity() {
      private lateinit var activityMainBinding: ActivityMainBinding
}

and my SymbolProcessor

 override fun process(resolver: Resolver): List<KSAnnotated> {
    val symbols = resolver.getSymbolsWithAnnotation(Angle::class.java.name)
     val groups = symbols.groupBy { if (it.validate()) "validate" else "invalidate" }
     val validateSymbols = groups["validate"]
     val invalidateSymbols = groups["invalidate"]
     ....
      return invalidateSymbols ?: emptyList()
 }

MainActivity can be scanned, but it is inside invalidateSymbols
after delete private lateinit var activityMainBinding: ActivityMainBinding, MainActivity comes to validateSymbols.
How to make it validate with viewBinding ?

KSP Version: 1.7.20-1.0.8

@neetopia
Copy link
Contributor

view binding does not support KSP, therefore you are running it in KAPT, mixing KAPT and KSP can cause some ordering issue, in which case you should not have dependencies between KAPT and KSP outputs. One solution for this is to specify build order in you build scripts to have KSP running after KAPT, and including KAPT's output into KSP's input (not sure if that has been handled properly in KAPT gradle plugin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants