0

I have a problem with project build. I wrote my own annotation processor. It is generating helper class to use with Android context based on other, contextless class. This generated class is intended to use inside XML files that uses Data Binding. I use Kotlin and kapt. So let's say I have a class Helper. My annotation processor generates HelperAndroid. And inside my Data Binding XML layout I have <import type="package.HelperAndroid" />.

My problem is that during first compilation I get an error: ****/ data binding error ****msg:Cannot resolve type for HelperAndroid file:path/to/xml/file.xml loc:lines ****\ data binding error ****. But in Build window in Android Studio I can see that my HelperAndroid class is generated before this error is raised (I added Diagnostic.Kind.NOTE logs to the console). On second attempt project compiles successfully.

Is there any way to force order of annotation processors?

Tiero
  • 107
  • 11
  • I think the problem is that this generated kotlin class does not have generated stub. Then of first compile data binding signals error, because there is no stub for generated kotlin class (but kotlin class itself is already generated). On second compile, since kotlin class is already there, its stub is generated and everything is fine at this point. Any ideas how to generate stubs for generated kotlin files? – Tiero Jul 23 '18 at 09:54
  • When I generate java code it is not working even in second build. – Tiero Jul 23 '18 at 12:21

0 Answers0