Android Question Using kotlin compiled library with JavaObject

agraham

Expert
Licensed User
Longtime User
Thanks to @DonManfred I can use trivial functions of a Kotlin compiled androidx library with JavaObject.
Use androidx aar with JavaObject? | B4X Programming Forum

However the library imports some Kotlin libraries
Java:
import kotlin.Metadata;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
and calling functions that use these imports results in errors like

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;

Are the relevant libraries in the SDK and is there a way to persuade B4A to include them in the apk?
 

JordiCP

Expert
Licensed User
Longtime User
I had to do something similar with a kotlin compiled android framework some months ago.

Most of the classes (at least in my case) were included in a couple of jars, so I downloaded them, added to the additional Libraries folder, and referenced with #AdditionalJar
https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
B4X:
#AdditionalJar: kotlin-stdlib-1.4.32
#AdditionalJar: kotlin-stdlib-jdk8-1.4.32
If it gives you errors (unsupported class file version 53.0), try with kotlin-stdlib-1.3.21 and kotlin-stdlib-jdk7-1.3.21
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Yess! Many thanks for the suggestion

I already saw that there is a kotlin folder in the SDK under tools\lib\external\org\jetbrains\kotlin with the 1.3.72 version of those two files file so, per your suggestion, I copied them to my additional libraries folder, referenced them with #AdditionalJar and that seems to work so far :)

I wonder if there is a way to get the B4A IDE to use them without copying.
 
Upvote 0
Top