Is there setup example how to build android app wi...
# kapt
e
Is there setup example how to build android app with annotation processing and kapt with JDK9+?
g
kapt works with JDK9+
no special config required But particular APs may have own problems
e
I have problem with Generated class from JDK
g
For example DataBinding do not work for us, even if you solve all problems with jaxb dependency
Dagger?
e
yes
ah, if databinding is still issue then I will not even try
g
it’s kapt bug that doesn’t propagate target JVM version to annotation processor
I’m not 100% sure
but bindings just not generating
no other exceptions, just no output
e
I found next workaround
Copy code
if (project.hasProperty('kapt')) {
    // Reference for 'kapt' DSL: <https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options>
    kapt {
      // we expect this closure to run over a org.jetbrains.kotlin.gradle.plugin.KaptExtension
      javacOptions {
        option('-source', '8')
        option('-target', '8')
      }
    }
  }
g
yes, it doesn’t work for me for some reason
e
same
oke, thank you!
g
So I use com.github.pengrad:jdk9-deps
this is just a dependency with Generated annotation
so it solves problem for me, but again, looks that binding do not work for some reason
e
oke, let me check google state about jdk9 and databinding
g
Could you try to build you project with fixed dagger
e
I will try today after lunch
I will keep you updated
g
Thanks
s
-source 8
works well in kotlin-android modules but broken in pure kotlin modules https://youtrack.jetbrains.com/issue/KT-33028
g
@Sergey Chelombitko Thanks!
e
@gildor After just adding your suggested dependency I have
Copy code
java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
g
Yes, it’s from bindings
Try to add Jaxb dependencies to kapt classpath:
Copy code
kapt "javax.xml.bind:jaxb-api:2.3.1"
kapt "com.sun.xml.bind:jaxb-core:2.3.0.1"
kapt "com.sun.xml.bind:jaxb-impl:2.3.2"
for some reason I also had this problem until I add the same to
annotationProcessor
classpath, but not sure why,
e
I should check databinding sources
probably why use it for xml parsing or whatever
g
Yes. of course
Anyway, because Jaxb removed from JVM default classes you have to add it
Could you please try? Also add this:
Copy code
annotationProcessor "javax.xml.bind:jaxb-api:2.3.1"
annotationProcessor "com.sun.xml.bind:jaxb-core:2.3.0.1"
annotationProcessor "com.sun.xml.bind:jaxb-impl:2.3.2"
I’m not sure is it required or not, but looks like that even tho we don’t use Java APT directly, I would expect that Kapt should populate it for APT, but I don’t have any real information is it correct or not, I just tried to make it work
e
It is required if you still have somewhere java class with databinding
g
Yes, but I would expect that Kapt sets own classpath to APT
e
oke
I ’m on the final stages
compileDebugJavaWithJavac
fails with the same class missing
g
even with annotationProcessor?
e
it fixes
I added it to the gradle file that is applied for all subprojects
but looks like app is not in this set
final strokes
it is green
let see if everything is correctly generated/working
I see data binding generated classes
g
Nice
e
The apk file looks correct. Installing…
It runs
Thank you!!!
g
👍
Will try later too. We just recently updated on AGP 3.5, maybe something fixed
e
I’m actually trying this on AGP 3.5
g
Yes, I got it, I tried on 3.4 as I remember
👍 1