# Dependency Injection in Legacy Code

DevFeed: [Dependency Injection in Legacy Code](<https://devfeed.tech/articles/dependency-injection-in-legacy-code-24906.md>)

Original publisher: [Read original article](<https://blog.blundellapps.co.uk/dependency-injection-in-legacy-code/>)

Author: blundell

Published: 2023-10-19T12:26:59Z

Content type: tutorial

Language: en

Sources: [Blundell](<https://devfeed.tech/sources/blundell.md>)

Topics: [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [Dagger](<https://devfeed.tech/topics/dagger.md>), [Android](<https://devfeed.tech/topics/android.md>), [android-development](<https://devfeed.tech/topics/android-development.md>), [legacy](<https://devfeed.tech/topics/legacy.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [dagger](<https://devfeed.tech/tags/dagger.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [development](<https://devfeed.tech/tags/development.md>), [intermediate](<https://devfeed.tech/tags/intermediate.md>), [legacy](<https://devfeed.tech/tags/legacy.md>), [legacy-code](<https://devfeed.tech/tags/legacy-code.md>), [reference](<https://devfeed.tech/tags/reference.md>)

## AI overview

This tutorial explains how to use Dagger and Hilt entry points to inject dependencies into Android legacy singletons and other classes that are not managed by the current architecture. It focuses on cases where the legacy code can access a Context and describes defining an entry-point interface for required bindings.

## Source excerpt

This post explains how you can inject dependencies into Android legacy singletons, or any classes that aren't conforming to your current Android architecture, using Dagger & Hilt. I'll cut straight to the chase, if you have a reference to Context, (which you usually always do in spaghetti legacy code) then you can use your normal [...] The post Dependency Injection in Legacy Code first appeared on Blundell.