3

直面している問題は AppModule に ContentProvider を挿入します。

私のアプリレベルモジュールは

module {
        single { TinyDB.getInstance(get()) }
        single { DataRepository(get()) }
        viewModel { HomeViewModel(get()) }
    }

モジュールで ContentProvider を使用する方法がわかりません

私はコードを試しました

val dataRepo = inject(DataRepository::class.java) 

これは私のコンテンツプロバイダーですが、この後、アプリがクラッシュし、logcat にエラーメッセージが表示されます

    java.lang.RuntimeException: Unable to get provider wastickerapps.newemojistickers.stickersforwhatsapp.whatsappUsages.StickerContentProvider: java.lang.IllegalStateException: StandAloneContext Koin instance is null
        at android.app.ActivityThread.installProvider(ActivityThread.java:5562)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5154)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5094)
        at android.app.ActivityThread.access$1600(ActivityThread.java:177)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
     Caused by: java.lang.IllegalStateException: StandAloneContext Koin instance is null
        at org.koin.standalone.StandAloneContext.getKoin(StandAloneContext.kt:68)
        at org.koin.standalone.KoinComponentKt.getKoinContext(KoinComponent.kt:42)
        at org.koin.standalone.KoinComponentKt.access$getKoinContext(KoinComponent.kt:1)
        at org.koin.standalone.KoinComponent$DefaultImpls.getKoin(KoinComponent.kt:36)
        at wastickerapps.newemojistickers.stickersforwhatsapp.whatsappUsages.StickerContentProvider.getKoin(StickerContentProvider.kt:27)
        at wastickerapps.newemojistickers.stickersforwhatsapp.whatsappUsages.StickerContentProvider.<init>(StickerContentProvider.kt:481)
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.Class.newInstance(Class.java:1650)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5547)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5154) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5094) 
        at android.app.ActivityThread.access$1600(ActivityThread.java:177) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1509) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:145) 
        at android.app.ActivityThread.main(ActivityThread.java:5942) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at 
4

1 に答える 1