Skip to content

Dagger 2.31

Compare
Choose a tag to compare
@Chang-Eric Chang-Eric released this 15 Jan 01:02
· 1094 commits to master since this release

What’s New

Dagger

Assisted Injection

Dagger now supports assisted injection. See the docs at https://dagger.dev/dev-guide/assisted-injection (daf0c66)

Hilt

@TestInstallIn

Adds a new @TestInstallIn feature to Hilt. This feature allows global test replacement modules to be defined instead of using @UninstallModules on individual tests. See the docs at (https://dagger.dev/hilt/testing#testinstallin) (d828472)

@HiltViewModel

Adds a new @HiltViewModel feature to Hilt. This replaces the @ViewModelInject AndroidX extension which will be deprecated in a future release.
@HiltViewModel differs from @ViewModelInject in that ViewModels are now injected from a ViewModelComponent with accompanying @ViewModelScope. See the docs for using @HiltViewModel at (https://dagger.dev/hilt/view-model) and docs on the ViewModelComponent at https://dagger.dev/hilt/components
(253ac8b)

Plugin local test support

When used with AGP 4.2.0+, the Hilt Gradle plugin will now transform local test classes by default. Usages of enableTransformForLocalTests can be removed if using AGP 4.2.0+. See the docs at https://dagger.dev/hilt/gradle-setup#gradle-plugin-local-tests (d69b00f)

Experimental fix to classpath issues

An experimental flag enableExperimentalClasspathAggregation has been introduced to the Hilt Gradle plugin to address issues where modules or entry points may be missed in multi-module Gradle projects when using implementation dependencies. It is recommended to use this flag since without it, if an implementation dependency hides a Hilt module/entry point, the resulting errors can be subtle and/or confusing and in the case of multibindings, may only manifest at runtime. However, there are also some build time tradeoffs to consider. See the docs at https://dagger.dev/hilt/gradle-setup#classpath-aggregation (239768b)

ApplicationComponent removed

The deprecated ApplicationComponent symbol has been removed. Users should migrate to SingletonComponent. This is intended to be a pure rename/functional no-op. (37cb8c8)