Is it possible to use Java code as part of an actual implementation in android/jvm source set? I have the Java class implemented and my code compiles, but at runtime the app crashes with
I need to workaround a Kotlin/Java interop bug in a library where an enum is not accessible in Kotlin because it is part of a non-accessible parent class.
This is exactly what I need, except I do have an android target, and not a jvm target. (This is an iOS/Android shared module.)
Unfortunately
Copy code
android {
withJava()
}
doesn’t work.
Jeff Lockhart
02/04/2021, 5:28 AM
Might have to resort to some ugly reflection as a workaround until the library gets a fix out.
b
Big Chungus
02/04/2021, 7:35 AM
Maybe try creating a jvm module for these things and then jyst consume it as a dependency in your main android module?
a
Animesh Sahu
02/04/2021, 9:11 AM
Did you mean
actual typealias SomeExpectClass = package.of.JavaClass
blob thinking upside down?
j
Jeff Lockhart
02/05/2021, 4:07 AM
No, I’m not typealiasing the actual directly to the Java implementation. I just need to use a Java shim to access one specific dependency as part of the android actual implementation.
I ended up writing some reflection code to access the inaccessible type in the Java dependency from Kotlin.