{"id":3451,"url":"https://github.com/stephanenicolas/toothpick","last_synced_at":"2025-05-15T15:06:45.629Z","repository":{"id":44907815,"uuid":"54854368","full_name":"stephanenicolas/toothpick","owner":"stephanenicolas","description":"A scope tree based Dependency Injection (DI) library for Java / Kotlin / Android.","archived":false,"fork":false,"pushed_at":"2022-06-24T16:31:51.000Z","size":2113,"stargazers_count":1133,"open_issues_count":50,"forks_count":114,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-07T20:11:11.782Z","etag":null,"topics":["android","android-dependency-injection","android-lifecycle","android-testing","android-viewmodel","androidx","dependency-injection","java","kotlin","kotlin-android"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephanenicolas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-28T00:23:34.000Z","updated_at":"2025-04-01T13:24:12.000Z","dependencies_parsed_at":"2022-08-25T11:01:58.385Z","dependency_job_id":null,"html_url":"https://github.com/stephanenicolas/toothpick","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanenicolas%2Ftoothpick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanenicolas%2Ftoothpick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanenicolas%2Ftoothpick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanenicolas%2Ftoothpick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephanenicolas","download_url":"https://codeload.github.com/stephanenicolas/toothpick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-dependency-injection","android-lifecycle","android-testing","android-viewmodel","androidx","dependency-injection","java","kotlin","kotlin-android"],"created_at":"2024-01-05T20:16:41.896Z","updated_at":"2025-05-15T15:06:45.612Z","avatar_url":"https://github.com/stephanenicolas.png","language":"Java","funding_links":[],"categories":["Libraries","IoC"],"sub_categories":["Dependency Injection"],"readme":"# Toothpick  *(a.k.a T.P. like a teepee)*\n\n\u003ctable style=\"border:0px\"\u003e\n  \u003ctr  style=\"border:0px\"\u003e\n    \u003ctd width=\"125\" style=\"border:0px\"\u003e\n      \u003cimg src=\"https://raw.github.com/stephanenicolas/toothpick/master/assets/logo.jpg\" width=\"125px\" /\u003e \n    \u003c/td\u003e\n    \u003ctd  style=\"border:0px\"\u003e\n      \u003ca alt=\"Build Status\" href=\"https://travis-ci.org/stephanenicolas/toothpick\"\u003e\n      \u003cimg src=\"https://travis-ci.org/stephanenicolas/toothpick.svg?branch=master\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n      \u003ca alt=\"Coverage Status\" href=\"https://coveralls.io/github/stephanenicolas/toothpick?branch=master\"\u003e\n      \u003cimg src=\"https://coveralls.io/repos/github/stephanenicolas/toothpick/badge.svg?branch=master\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n      \u003ca alt=\"License\" href=\"https://raw.githubusercontent.com/stephanenicolas/toothpick/master/LICENSE\"\u003e\n      \u003cimg src=\"http://img.shields.io/:license-apache-blue.svg\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n      \u003ca alt=\"Maven Central\" href=\"http://search.maven.org/#search|gav|1|g:'com.github.stephanenicolas.toothpick'%20AND%20a:'toothpick'\"\u003e\n      \u003cimg src=\"https://img.shields.io/maven-central/v/com.github.stephanenicolas.toothpick/toothpick.svg?style=flat\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n    \u003c/td\u003e\n    \u003ctd  style=\"border:0px\"\u003e\n      \u003ca alt=\"Android Dev Weekly\" href=\"http://androidweekly.net/issues/issue-207\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Android%20Weekly-%23207-brightgreen.svg\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n      \u003ca alt=\"Android Arsenal\" href=\"http://android-arsenal.com/details/1/3646\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-Toothpick-brightgreen.svg?style=flat\"/\u003e\u003c/a\u003e\n      \u003cbr/\u003e\n      \u003ca alt=\"Incap: isolating\" href=\"https://github.com/gradle/gradle/blob/master/subprojects/docs/src/docs/userguide/java_plugin.adoc#isolating-annotation-processors\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/incap-isolating-4AC31D?style=flat\"/\u003e\u003c/a\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n      \u003ca href=\"https://github.com/stephanenicolas/toothpick/wiki\"\u003e\n      Visit TP wiki !\n      \u003c/a\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## What is Toothpick ?\n \nToothpick is a scope tree based Dependency Injection (DI) library for Java.\n\nIt is a full-featured, runtime based, but reflection free, implementation of [JSR 330](https://github.com/stephanenicolas/toothpick/wiki/Relation-to-JSR-330).\n\n## What does Toothpick offer ?\n\n```\n//a typical Toothpick scope tree during the execution of an Android app.\n\n           @ApplicationScope \n             /          |    \\  \n            /           |     \\\n           /            |      \\\n   @ViewModelScope      |   Service 2\n         /              | \n        /            Service 1  \n       /            \n @Activity1Scope\n      /\n     /\nActivity 1\n   /   \\\n  /   Fragment 2\n /\nFragment 1\n```\n\nScopes offer to compartmentalize memory during the runtime of an app and prevent memory leaks.\nAll dependencies created via Toothpick, and available for injections, will be fully garbage collected when this scope is closed.\nTo learn more about scopes, read [TP wiki](https://github.com/stephanenicolas/toothpick/wiki/Scopes#what-is-a-scope-).\n\nToothpick is :\n* pure java (Android support is provided: \"Smoothie\", Kotlin support is provided by \"KTP\")\n* [fast](https://github.com/stephanenicolas/toothpick/wiki/FAQ#how-does-toothpick-perform-compared-to-dagger-2-), it doesn't use reflection but [annotation processing](https://github.com/stephanenicolas/toothpick/wiki/Factories-and-Member-Injectors)\n* TP supports [incremental annotation processing (isolating)](https://github.com/gradle/gradle/blob/master/subprojects/docs/src/docs/userguide/java_plugin.adoc#isolating-annotation-processors).\n* simple, flexible, extensible \u0026 powerful, [robust \u0026 tested](https://coveralls.io/github/stephanenicolas/toothpick?branch=master)\n* thread safe\n* [documented](https://github.com/stephanenicolas/toothpick/wiki) \u0026 [Open Source](https://raw.githubusercontent.com/stephanenicolas/toothpick/master/LICENSE)\n* [scope safe](https://github.com/stephanenicolas/toothpick/wiki/Scope-Resolution) : it enforces leak free apps\n* [test oriented](https://github.com/stephanenicolas/toothpick/blob/master/toothpick-sample/src/test/java/toothpick/sample/SimpleEntryPointTestWithRules.java) : it makes tests easier\n* is a candidate of choice for Android or any other context based framework (such as web containers)\n\n## Examples\n\nThis is the example:\n* https://github.com/stephanenicolas/toothpick/tree/master/toothpick-sample\n\n## Setup\n\nThe latest version of TP is provided by a badge at the top of this page.\n\nFor Android : \n```groovy\n#android setup using gradle 5.5.1\nbuildscript {\n  repositories {\n    google()\n    jcenter()\n  }\n  dependencies {\n    classpath 'com.android.tools.build:gradle:3.4.x'\n  }\n}\n\n...\n#for java\ndependencies {\n  implementation 'com.github.stephanenicolas.toothpick:toothpick-runtime:3.x'\n  // and for android -\u003e implementation 'com.github.stephanenicolas.toothpick:smoothie-androidx:3.x'\n  annotationProcessor 'com.github.stephanenicolas.toothpick:toothpick-compiler:3.x'\n\n  //highly recommended\n  testImplementation 'com.github.stephanenicolas.toothpick:toothpick-testing-junit5:3.x'\n  testImplementation 'mockito or easymock'\n}\n\n#for kotlin\ndependencies {\n  implementation 'com.github.stephanenicolas.toothpick:ktp:3.x'\n  kapt 'com.github.stephanenicolas.toothpick:toothpick-compiler:3.x'\n\n  //highly recommended\n  testImplementation 'com.github.stephanenicolas.toothpick:toothpick-testing-junit5:3.x'\n  testImplementation 'mockito or easymock'\n}\n\n```\n\nFor java:\n```xml\n\u003c!--java setup with maven --\u003e\n  \u003cdependencies\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.github.stephanenicolas.toothpick\u003c/groupId\u003e\n      \u003cartifactId\u003etoothpick-compiler\u003c/artifactId\u003e\n      \u003cversion\u003e3.x\u003c/version\u003e\n      \u003cscope\u003ecompile\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003ecom.github.stephanenicolas.toothpick\u003c/groupId\u003e\n      \u003cartifactId\u003etoothpick-runtime\u003c/artifactId\u003e\n      \u003cversion\u003e3.x\u003c/version\u003e\n      \u003cscope\u003ecompile\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \n    \u003c!-- highly recommended--\u003e\n    \u003cdependency\u003e \n      \u003cgroupId\u003ecom.github.stephanenicolas.toothpick\u003c/groupId\u003e\n      \u003cartifactId\u003etoothpick-testing\u003c/artifactId\u003e\n      \u003cversion\u003e3.x\u003c/version\u003e\n      \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n    \u003cdependency\u003e\n    \u003ceasymock or mockito\u003e\n    \u003c/dependency\u003e\n  \u003c/dependencies\u003e\n```\n## Support\n\nTP is actively maintained and we provide support to questions via the [Toothpick-di](https://stackoverflow.com/questions/tagged/toothpick-di) tag on Stack Over Flow. \n\nAsk questions on Stack Over Flow while keeping the GitHub issue board for real issues. Thx in advance !\n\n## Talks \u0026 Articles\n\n* A Dependency Injection Showdown - [Pro Android Dev article](https://proandroiddev.com/a-dependency-injection-showdown-213339c76515)\n* Toothpick 3 — a hidden gem in the DI world - [Medium article](https://medium.com/swlh/toothpick-3-a-hidden-gem-194ae6ee8671)\n* How I learned to love unit testing with Toothpick - [Groupon's medium blog article](https://medium.com/groupon-eng/how-i-learned-to-love-unit-testing-with-toothpick-13ad305b35d)\n* Droidcon, Boston 2017 - [Slides](https://speakerdeck.com/dlemures/toothpick-a-fresh-approach-to-di-including-unit-testing) \u0026 [Video](https://news.realm.io/news/droidcon-boston-daniel-molinero-toothpick-dependency-injection-android/)\n* Migrating off RoboGuice 3 (to Toothpick) - [Part 1](https://medium.com/@markchristopherng/migrating-off-roboguice-3-part-1-cee0875f6620) \u0026 [Part 2](https://medium.com/@markchristopherng/migrating-off-roboguice-3-part-2-c06644d2d1ef)\n* Mobius, Saint Petersburg 2017 - [Slides](https://speakerdeck.com/stephanenicolas/tp-mobile-era-2016-final-compressed)\n* Mobius, Saint Petersburg 2017 - DI frameworks \u0026 Internals [Slides](https://speakerdeck.com/stephanenicolas/comparing-di-frameworks)\n* Android Makers, Paris 2017 - [Slides](https://speakerdeck.com/stephanenicolas/tp-mobile-era-2016-final-compressed) \u0026 [Video](https://www.youtube.com/watch?v=rn4EAzimslw)\n* DroidCon, Kaigi 2017 - [Slides](https://speakerdeck.com/stephanenicolas/tp-mobile-era-2016-final-compressed)\n* Andevcon, San Francisco 2016 - [Slides](https://speakerdeck.com/stephanenicolas/tp-mobile-era-2016-final-compressed)\n* DroidCon, Krakow 2016 - TP Vs Dagger 2 Talk from Danny Preussler [slides](http://www.slideshare.net/dpreussler/demystifying-dependency-injection-dagger-and-toothpick)\n* Mobile Era, Oslo 2016 - [Slides](https://speakerdeck.com/stephanenicolas/tp-mobile-era-2016-final-compressed)\n* Droidcon, Berlin 2016 - [Slides](https://speakerdeck.com/dlemures/toothpick-and-dependency-injection) - [Sketch notes](https://twitter.com/TeresaHolfeld/status/743026908552663041)\n* Android Leaks 2016 - [podcast in French](http://androidleakspodcast.com/2016/09/25/episode-4-de-la-dague-au-cure-dent-en-passant-par-un-petit-jus/)\n* DevFest Belgium 2016 - [video in French](https://www.youtube.com/watch?v=ytBmu5ciPCQ)\n* DevFest Siberia 2017 - [video in Russian](https://www.youtube.com/watch?v=EOFrA-MHbjU)\n* DevFest North 2017 - [video in Russian](https://www.youtube.com/watch?v=t55nFVurCHw)\n* [Toothpick: a simple DI for Android development (Russian)](https://medium.com/@alaershov/toothpick-di-android-1-intro-ru-151015616f0?source=friends_link\u0026sk=ccfdda35cd968f1cd9986ab4a8cf0016)\n\n# Wanna know more ?\n\nVisit [Toothpick's wiki](https://github.com/stephanenicolas/toothpick/wiki) !\n\n# Alternative Dependency Injection (DI) engines for Android\n\n* ~~[RoboGuice](https://github.com/roboguice/roboguice)~~ (deprecated)\n* ~~[Dagger 1](https://github.com/square/dagger)~~ (deprecated)\n* [Dagger 2](https://github.com/google/dagger)\n* [transfuse](http://androidtransfuse.org/)\n* [lightsaber](https://github.com/MichaelRocks/lightsaber)\n* ~~[tiger](https://github.com/google/tiger)~~ (deprecated)\n* [feather](https://github.com/zsoltherpai/feather)\n* [proton](https://github.com/hnakagawa/proton)\n* [koin](https://github.com/InsertKoinIO/koin)\n* [Kodein-DI](https://github.com/Kodein-Framework/Kodein-DI)\n\n# Libs / Apps using TP 2\n\n* [Okuki](https://github.com/wongcain/okuki) is a simple, hierarchical navigation bus and back stack for Android, with optional Rx bindings, and Toothpick DI integration.\n* [KotlinWeather](https://github.com/ekamp/KotlinWeather) is a simple example of using ToothPick with Kotlin and gradle integration using kapt.\n\n# Credits\n\nTP 1 \u0026 3 have been developped by Stephane Nicolas and Daniel Molinero Reguera.\nMost of the effort on version 2 has been actively supported by Groupon. Thanks for this awesome OSS commitment !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanenicolas%2Ftoothpick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanenicolas%2Ftoothpick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanenicolas%2Ftoothpick/lists"}