Dagger 2.34
What’s New in Dagger
Bug fixes
- Fixed an issue where in rare cases subcomponent builder bindings might accidentally attach to the wrong parent (c2d097f)
- Build performance improvements (47123ec, 1caa7f0, e2f2b2d)
What’s New in Hilt
Hilt has a new flag, -Adagger.hilt.shareTestComponents
, that enables tests with no test-specific bindings (e.g. @BindValue
fields or @InstallIn
modules within the test class) to share the same generated component. This flag should help improve build times by avoiding generating duplicate components for tests with the same bindings (faebc3c).
Note: This flag is currently disabled by default, but will be enabled by default in a future release of Hilt. For more information on how to enable this flag as well as some caveats, see the docs
New breaking changes
The alpha androidx extension @ViewModelInject
is no longer supported. @ViewModelInject
has been deprecated since androidx.hilt 1.0.0-alpha03 and was removed in androidx.hilt 1.0.0-beta01. Hilt now falls back to the base activity/fragment default ViewModelProviderFactory (3778ee2)
Migration steps:
Users of @ViewModelInject
can migrate to @HiltViewModel which was added in Dagger 2.31.
- Add
@HiltViewModel
annotation to the class - Replace the
@ViewModelInject
annotation on the constructor with@Inject
. - Remove
@Assisted
from theSavedStateHandle
constructor parameter, if it exists - Remove the old
androidx.hilt:hilt-lifecycle-viewmodel
dependency from yourbuild.gradle
file
Bug fixes
- Update the androidx fragment, lifecycle and activity dependencies which contain patch fixes. (efcdbe1, 57255db)
- Fix #2511: updates the kotlinx-metadata dependency. (b42731b)
- Fix issue with proguard removing entry points by adding proguard keep rules. (96171b0)
- Fix #2456: Rename
init()
method in generated Activity to avoid conflict with user method of same name. (1c66033) - Reduce the possibility of KAPT logging warnings due to no processor supporting
disableAndroidSuperclassValidation
when no Android entry points are in the source module. (c70cf2d) - Fix #2070: Clears the
Fragment
reference inFragmentContextWrapper
afterFragment#onDestroy()
to prevent leaks if a non-Hilt View outlives the Hilt Fragment that created it. (7f4c3a2)