We currently have a project which includes some java files which successfully build into the package.
However, when I placed a kotlin file in the same directory, the class it contained could not be found when compiling a java file which referenced it.
I presume the tool which builds kotlin files is not run.
How do I use kotlin files in my project similar to how Java files can talk to C++ code via JNI
Hi Martin,
Kotlin isn’t supported out of the box. To use Kotlin in your project, you’ll need to update your UPL.xml (which presumably already exists to copy the kotlin sources) to add the Gradle Kotlin settings and dependencies as follows:
<buildscriptGradleAdditions>
<insert>
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
}
</insert>
</buildscriptGradleAdditions>
<buildGradleAdditions>
<insert>apply plugin: 'kotlin-android'
android {
kotlinOptions {
jvmTarget = "1.8"
}
}
</insert>
</buildGradleAdditions>
Best regards.
1 Like