As a Java developer I've become accustomed to having dependency injection available in applications. For Android though, I am especially wary of performance. What are the performance implications for using Guice in an Android app? I assume there is some overhead, but is it significant enough that I should avoid using Guice?
My use of it would likely just be to inject a few shared objects into various activities.
Supposedly faster than Guice, because Dagger works by generating code up-front, whereas Guice uses Reflection at runtime.
Spring allows you to omit the @Autowired annotation when there's only one constructor. Guice allows binding to a Provider, as well as injecting a Provider of your class, even when your class has no Provider binding.
Guice is base on reflection, while Dagger is generating extra code during compile-time; reflection is much slower than the pre-generated code. Dagger is often used in Android development(reflection is even slower in Android) Dagger has simpler APIs, and the stacktrace is easier to understand.
Guice is an open source, Java-based dependency injection framework. It is quiet lightweight and is actively developed/managed by Google.
I would avoid using DI in android as google suggests: http://developer.android.com/training/articles/memory.html#DependencyInjection
Dagger solves some timing problems but still wastes memory for no real benefit.
As of version 3, Guice caches reflective objects to improve performance. There's at least one bug out against dalvik to make annotation lookups faster, but the current performance is workable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With