A scope tree based, reflection-free Dependency Injection library for Java, Kotlin, and Android.
Toothpick is a Dependency Injection library for Java, Kotlin, and Android that uses a scope tree architecture to manage dependencies. It implements JSR 330 without reflection, relying on annotation processing for performance. The library helps prevent memory leaks by compartmentalizing dependencies within scopes that are garbage collected when closed.
Android and Java/Kotlin developers building applications that require efficient, testable dependency management, especially those working in context-based frameworks.
Developers choose Toothpick for its reflection-free performance, scope-based memory safety, and strong support for testing. It offers a flexible, extensible alternative to other DI frameworks with a focus on simplicity and robustness.
A scope tree based Dependency Injection (DI) library for Java / Kotlin / Android.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements a hierarchical scope tree that compartmentalizes dependencies, ensuring they are garbage collected when scopes close, effectively preventing memory leaks in Android and context-based apps.
Uses annotation processing instead of reflection, resulting in faster runtime performance compared to reflection-based DI libraries, as highlighted in the README's comparison to Dagger 2.
Provides dedicated testing modules and JUnit rules, making unit testing easier by allowing straightforward mocking and dependency injection in test environments, as shown in the sample code.
Supports isolating annotation processors in Gradle, enabling incremental compilation for faster build times, which is particularly beneficial for large projects.
Compared to Dagger 2, Toothpick has a narrower user base and fewer third-party integrations, which can limit access to community resources, plugins, and troubleshooting support.
Requires explicit configuration of annotation processors in build scripts (e.g., Gradle or Maven), adding initial setup overhead and potential build-time increases, especially for newcomers.
The scope tree architecture, while powerful, introduces additional complexity that developers must master to avoid misconfigurations, such as improper scope closure or dependency resolution errors.
Toothpick is an open-source alternative to the following products:
Koin is a lightweight dependency injection framework for Kotlin and Android applications, using a DSL and functional APIs for easy setup and management.
RoboGuice is a dependency injection framework for Android that uses Google Guice to simplify Android development by reducing boilerplate code.
Kodein-DI is a dependency injection framework for Kotlin that is easy to use, concise, and supports both Android and multiplatform projects.
Dagger 2 is a dependency injection framework for Java and Android, using compile-time code generation to provide efficient and maintainable dependency management.