Reputation: 60
I found in official koin docs that properties default location is the src/main/resources/koin.properties, but when I trying to use it, I getting this beautiful exception. Can someone explain me how's koin works with properties on Android please?
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app.AppApplication, PID: 12387
java.lang.RuntimeException: Unable to create application com.example.app.AppApplication: org.koin.core.error.NoPropertyFileFoundException: No properties found for file 'koin.properties'
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6608)
at android.app.ActivityThread.access$1500(ActivityThread.java:235)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1916)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:225)
at android.app.ActivityThread.main(ActivityThread.java:7563)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:994)
Caused by: org.koin.core.error.NoPropertyFileFoundException: No properties found for file 'koin.properties'
at org.koin.core.registry.PropertyRegistry.loadPropertiesFromFile(PropertyRegistry.kt:100)
at org.koin.core.KoinApplication.fileProperties(KoinApplication.kt:92)
Class with onCreate():
override fun onCreate() {
super.onCreate()
startKoin {
androidLogger(Level.NONE)
androidContext(this@AppApplication)
//copied from docs
// Load properties from the default location
// (i.e. `/src/main/resources/koin.properties`)
fileProperties("koin.properties") //CRASH
modules(appModule)
}
}
Upvotes: 0
Views: 753
Reputation: 60
Thing is that i should use use fileProperties()
, without parameters, instead fileProperties("filename")
.
And then just use getProperty("property_name")
.
That's because /src/main/resources/koin.properties
is default location INCLUDING a filename...
Upvotes: 1