InjektionException: No registered instance or factory for type com.brianegan.bansa.Store
DavidMihola opened this issue · 6 comments
Hi,
I just wanted to try your Bansa counter example (by the way, I have to chuckle every time I misread this as "Bansa counterexample") and it crashed with the following exception:
java.lang.RuntimeException: Unable to instantiate application com.brianegan.bansa.counter.Application: uy.kohesive.injekt.api.InjektionException: No registered instance or factory for type com.brianegan.bansa.Store<com.brianegan.bansa.counter.ApplicationState, com.brianegan.bansa.Action>
at android.app.LoadedApk.makeApplication(LoadedApk.java:526)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4390)
at android.app.ActivityThread.access$1500(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1260)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: uy.kohesive.injekt.api.InjektionException: No registered instance or factory for type com.brianegan.bansa.Store<com.brianegan.bansa.counter.ApplicationState, com.brianegan.bansa.Action>
at uy.kohesive.injekt.registry.default.DefaultRegistrar.getInstance(DefaultRegistrar.kt:99)
at uy.kohesive.injekt.api.InjektScope.getInstance(Scope.kt)
at com.brianegan.bansa.counter.Application.<init>(Application.kt:30)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.Instrumentation.newApplication(Instrumentation.java:990)
at android.app.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:521)
... 11 more
I haven't done much Kotlin and haven't used Injekt at all - could you tell me what I am doing wrong?
Ah, very interesting problem! Is this on an Android 4.x device by chance? I've been developing against Lollipop+ Devices and hadn't tried out Injekt with 4.x devices just yet.
Also "Bansa Counterexample" haha -- might need to change that one up :P
4.x indeed. An LG G2 with Android 4.4.2, to be precise.
Unfortunately, I won't have access to any Android 5 devices before Tuesday to try Bansa on.
But maybe I have the time to look into Injekt and Android 4.
Good catch! This is my first time using Injekt, was trying it out as an experiment. I've tried a couple other sample projects and saw similar errors. I'll find the root cause and fix it up for 4.x devices.
Thanks for the report, and sorry about the trouble!
Great! I am looking forward to trying Bansa!
Hey, just as a heads up, I'm working with the author of the dependency Injection framework to figure out the 4.x issues: kohesive/injekt#33
In the meantime, I'll probably rip out this form of dependency injection in favor of 1) No injection (It's not necessary for a lot of these smaller apps). or 2) Replace it with dagger so it works everywhere.
Thanks again for reporting this bug!
As a heads up: Bansa works fine with Android 4.x once the dependency injection is removed.