I would like to use Koin library from Java. According to this tutorial, Koin modules can be written in Kotlin even using Java in the rest of a project.
https://insert-koin.io/docs/quickstart/android-java/
I use also @JvmField annotation for the module field because in the source code of this tutorial it is used
In my project I use koinInjector which is a list of modules
import org.koin.android.java.KoinAndroidApplication;
import org.koin.core.KoinApplication;
import static org.koin.core.context.DefaultContextExtKt.startKoin;
import static com.x.y.KoinInjectorKt.koinInjector;
public class App extends Singleton {
@Override
public void onCreate() {
super.onCreate();
KoinApplication koin = KoinAndroidApplication
.create(this)
.modules(koinInjector);
startKoin(koin);
}
}
KoinInjector.kt:
@JvmField
val koinInjector: List<Module> = listOf(
localDbModule,
)
But during build I get the error:
error: cannot find symbol
import static com.x.y.KoinInjectorKt.koinInjector;
^
symbol: class KoinInjectorKt
location: package com.x.y
koinInjectoris declared? - Jenea VranceanuKoinInjector. Whereas the nameKoinInjectorKtin import was generated automatically - jdevbuild.gradlefile? - Jeroen Steenbeeke