GitPedia

Tangle

Android injection using the Anvil compiler plugin

From RBusarow·Updated April 20, 2026·View on GitHub·

Tangle creates [Dagger] bindings for Android classes using the [Anvil] Kotlin compiler plugin. This is meant to be an alternative to [Hilt], for those who'd prefer to enjoy the faster compilation and better flexibility of Anvil. The project is written primarily in Kotlin, distributed under the Apache License 2.0 license, first published in 2021. Key topics include: android, anvil, dagger2, dependency-injection, kotlin.

Latest release: 0.15.1
August 24, 2022View Changelog →

Maven Central
Gradle Plugin Portal
License


Tangle creates Dagger bindings for Android classes using the Anvil Kotlin compiler plugin. This
is meant to be an alternative to Hilt, for those who'd prefer to enjoy the faster compilation and
better flexibility of Anvil.

Since Tangle is an extension upon Anvil, its code generation will be applied to Kotlin files
only.

Please see the project website for full documentation.

Features

ViewModel Injection

kotlin
class MyViewModel @VMInject constructor( val repository: MyRepository, @TangleParam("userId") // pulls the "userId" argument out of SavedStateHandle val userId: String ) : ViewModel() @Composable fun MyComposable( navController: NavController, viewModel: MyViewModel = tangleViewModel() ) { /* ... */ } class MyFragment : Fragment() { val viewModel: MyViewModel by tangleViewModel() }

Inject ViewModels, including scoped SavedStateHandle arguments. Use the @TangleParam annotation to automatically extract navigation/Bundle arguments and inject them directly. read more

Fragment Injection with Bundle arguments

kotlin
@ContributesFragment(AppScope::class) class MyFragment @FragmentInject constructor( val repository: MyRepository ) : Fragment() { val name: String by arg("name") @FragmentInjectFactory interface Factory { fun create( @TangleParam("name") name: String ): MyFragment } }

Use constructor injection in Fragments, with optional AssistedInject-like factories for type-safe Bundle arguments. Bindings are created automatically. read more

Worker Injection

kotlin
@TangleWorker class MyWorker @AssistedInject constructor( @Assisted context: Context, @Assisted params: WorkerParameters ) : CoroutineWorker(context,params) { override suspend fun doWork(): Result { /* ... */ } }

Use Dagger's @AssistedInject and @Assisted annotations and @TangleWorker to inject any ListenableWorker. read more

License

text
Copyright (C) 2021 Rick Busarow Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributors

Showing top 6 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from RBusarow/Tangle via the GitHub API.Last fetched: 6/20/2026