https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
m

Mgj

07/07/2020, 10:53 AM
Is it possible to use Android databinding with kotlin multiplatform? I'm able to enable databinding in the module
build.gradle
:
Copy code
dataBinding {
        enabled = true
    }
But since i have custom binding adapters i also need
kotlin-kapt
plugin. As soon as i add it i get a build error:
Copy code
C:\x\app\build\generated\source\kapt\release\androidx\databinding\library\baseAdapters\BR.java:3: error: package javax.annotation does not exist
import javax.annotation.Generated;


C:\x\app\build\generated\source\kapt\release\y\databinding\FragmentLoginBindingImpl.java:8: error: package javax.annotation does not exist
@javax.annotation.Generated("Android Data Binding")
Perhaps i need to enable the
kotlin-kapt
plugin only for the android target (since it seems to have a dependency on javax.annotation) - How can i do this?
Adding this as a root dependency seems to fix it... 🤔
Copy code
dependencies {
    // Fix of package javax.annotation does not exist import javax.annotation.Generated in DataBinding code
    compileOnly("javax.annotation:jsr250-api:1.0")
}
Or not... i can now build from commandline but building from IntelliJ fails 😕
6 Views