Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Fix NoPropertyFileFoundException crash by adding koin.properties #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aldoKelvianto
Copy link

If we run the App from master branch, user will get the following error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: koin.sampleapp.mvvm, PID: 21906
    java.lang.RuntimeException: Unable to create application fr.ekito.myweatherapp.MainApplication: org.koin.core.error.NoPropertyFileFoundException: No properties found for file '/koin.properties'
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5500)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6221)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
     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:84)
        at org.koin.core.KoinApplication.fileProperties$default(KoinApplication.kt:83)
        at fr.ekito.myweatherapp.MainApplication$onCreate$1.invoke(MainApplication.kt:22)
        at fr.ekito.myweatherapp.MainApplication$onCreate$1.invoke(MainApplication.kt:15)
        at org.koin.core.context.GlobalContextKt.startKoin(GlobalContext.kt:72)
        at fr.ekito.myweatherapp.MainApplication.onCreate(MainApplication.kt:21)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5497)
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:163) 
        at android.app.ActivityThread.main(ActivityThread.java:6221) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)

Thats because fileProperties will use default fileName location that is src/main/resources/koin.properties.

fun fileProperties(fileName: String = "/koin.properties"): KoinApplication {

This PR add koin.properties so the App won't crashed upon launching.

@tw-Frey
Copy link

tw-Frey commented Nov 14, 2019

issue #5

use androidFileProperties() instead of fileProperties()
because koin.properties in assets fold

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants