Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

toothpick

> 测试质量
Open source

A scope tree based Dependency Injection (DI) library for Java / Kotlin / Android.

1.1K stars0 likes3 views
WebsiteGitHub

About

A scope tree based Dependency Injection (DI) library for Java / Kotlin / Android.

Toothpick (a.k.a T.P. like a teepee)

  Visit TP wiki !

What is Toothpick ?

Toothpick is a scope tree based Dependency Injection (DI) library for Java.

It is a full-featured, runtime based, but reflection free, implementation of JSR 330.

What does Toothpick offer ?

bash
//a typical Toothpick scope tree during the execution of an Android app.

           @ApplicationScope 
             /          |    \  
            /           |     \
           /            |      \
   @ViewModelScope      |   Service 2
         /              | 
        /            Service 1  
       /            
 @Activity1Scope
      /
     /
Activity 1
   /   \
  /   Fragment 2
 /
Fragment 1

Scopes offer to compartmentalize memory during the runtime of an app and prevent memory leaks. All dependencies created via Toothpick, and available for injections, will be fully garbage collected when this scope is closed. To learn more about scopes, read TP wiki.

Toothpick is :

  • pure java (Android support is provided: "Smoothie", Kotlin support is provided by "KTP")
  • fast, it doesn't use reflection but annotation processing
  • TP supports incremental annotation processing (isolating).
  • simple, flexible, extensible & powerful, robust & tested
  • thread safe
  • documented & Open Source
  • scope safe : it enforces leak free apps
  • test oriented : it makes tests easier
  • is a candidate of choice for Android or any other context based framework (such as web containers)

Examples

This is the example:

  • https://github.com/stephanenicolas/toothpick/tree/master/toothpick-sample

Setup

The latest version of TP is provided by a badge at the top of this page.

For Android :

…

For java:

xml

  
    
      com.github.stephanenicolas.toothpick
      toothpick-compiler
      3.x
      compile
    
    
      com.github.stephanenicolas.toothpick
      toothpick-runtime
      3.x
      compile
    
    
    
     
      com.github.stephanenicolas.toothpick
      toothpick-testing
      3.x
      test
    
    
    
    
  

Support

TP is actively maintained and we provide support to questions via the Toothpick-di tag on Stack Over Flow.

Ask questions on Stack Over Flow while keeping the GitHub issue board for real issues. Thx in advance !

Talks & Articles

  • A Dependency Injection Showdown - Pro Android Dev article
  • Toothpick 3 — a hidden gem in the DI world - Medium article
  • How I learned to love unit testing with Toothpick - Groupon's medium blog article
  • Droidcon, Boston 2017 - Slides & Video
  • Migrating off RoboGuice 3 (to Toothpick) - Part 1 & Part 2
  • Mobius, Saint Petersburg 2017 - Slides
  • Mobius, Saint Petersburg 2017 - DI frameworks & Internals Slides
  • Android Makers, Paris 2017 - Slides & Video
  • DroidCon, Kaigi 2017 - Slides
  • Andevcon, San Francisco 2016 - Slides
  • DroidCon, Krakow 2016 - TP Vs Dagger 2 Talk from Danny Preussler slides
  • Mobile Era, Oslo 2016 - Slides
  • Droidcon, Berlin 2016 - Slides - Sketch notes
  • Android Leaks 2016 - podcast in French
  • DevFest Belgium 2016 - video in French
  • DevFest Siberia 2017 - video in Russian
  • DevFest North 2017 - video in Russian
  • Toothpick: a simple DI for Android development (Russian)

Wanna know more ?

Visit Toothpick's wiki !

Alternative Dependency Injection (DI) engines for Android

  • RoboGuice (deprecated)
  • Dagger 1 (deprecated)
  • Dagger 2
  • transfuse
  • lightsaber
  • tiger (deprecated)
  • feather
  • proton
  • koin
  • Kodein-DI

Libs / Apps using TP 2

  • Okuki is a simple, hierarchical navigation bus and back stack for Android, with optional Rx bindings, and Toothpick DI integration.
  • KotlinWeather is a simple example of using ToothPick with Kotlin and gradle integration using kapt.

Credits

TP 1 & 3 have been developped by Stephane Nicolas and Daniel Molinero Reguera. Most of the effort on version 2 has been actively supported by Groupon. Thanks for this awesome OSS commitment !

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaandroidandroid-dependency-injectionandroid-lifecycleandroid-testing

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.