I plan to use Multiplatform as UI to provide information of embedded devices. Existing Java libraries are to be used to communicate with the embedded devices.
I created a sample project using the Kotlin Multiplatform Wizard. Afterwards I added a subproject named „shared-comembedded“ using plugin „java-library“ containing only only simple Java class.
The only changes within the generated sources from the Kotlin Multiplatform Wizard are
- within the file App.kt using the function getString() of the Java class myjava part of the subproject „shared-comembedded“.
The import statement „import com.sample.shared.comembedded.myjava“ was added manually. - settings.gradle.kts includes the library
- composeApp/build.gradle.kts> added dependency for commonMain
The app can be compiled and executed. However, Intellij and Android Studio mark „myjava()“ red and shows the error „Unresolved reference: myjava“ and provides the solution „Add dependency on module kmmIssueJavaImport.shared-comembedded.main“.
Executing this solution results in following additional lines within the file „composeApp/build.gradle.kts“:
dependencies {
implementation (project(":shared-comembedded"))
}
The described error messages remains unchanged.
Is this behavior an error of the IDEs or is any additional configuration necessary?
Please find attached the sample source code.
kmmIssueJavaImport.tar.gz (1.3 MB)