Releases: google/dagger
Dagger 2.43
Whatβs New In Dagger
Potentially Breaking Changes
- Note: Dagger 2.43/2.43.1 require java 11 due to a change in Dagger's XProcessing dependency.
However, this requirement has been recently reverted in XProcessing
and Dagger 2.43.2 should support java 8 again (see issue #3495).
Bug Fixes
- Fixes #3401 where Dagger generated mismatched parameter names in subcomponent factory method implementations when the original factory method is in a separate build unit from the component that implements it.
Whatβs New In Hilt
Potentially Breaking Changes
- Hilt now throws if the base activity/fragment classβs
getDefaultViewModelProviderFactory()
returns null. This is unlikely to happen though unless overridden by the user to return null. (9eee8e4) - As part ViewModel bug fixes, dependencies were updated as below.
androidx.navigation
users will need to update to 2.5.0 to interoperate. These libraries require building with SDK 31. To build with SDK 31, AGP users will need to use AGP 7.0+. This will also require using JDK11.androidx.activity
andandroidx.fragment
to 1.5.0androidx.lifecycle
to 2.5.0androidx.savedstate
to 1.2.0
Bug Fixes
- Fix #3464 where SPI plugins were not being invoked with Hilt's Gradle Plugin aggregation (
enableAggregatingTask
) turned on. (b838876) - Fixes #2328 and #3232 where getting multiple instances of
@HiltViewModel
with different keys would cause a crash. - Fixes #2152. hiltNavGraphViewModels is now no longer necessary to use
@HiltViewModel
with navigation backstack entries as the owner. The defaultViewModelProvider.Factory
from activities and fragments can be used directly with the backstack entry as the owner. (74ea765) - Make it so that map keys used with
@BindValueIntoMap
in Kotlin code do not need to use the@field
notation. (e591833)
Dagger 2.42
Whatβs new in Dagger
Potentially breaking changes
As of this release, Daggerβs generated class will no longer extend the user-defined @Component
annotated class (885b16d). This change was done to improve build times in certain scenarios by avoiding a known javac bottleneck. However, it may also be a breaking change for some users. For example
// This will fail as of Dagger version 2.42
DaggerMyComponent component = DaggerMyComponent.create();
// Do this instead:
MyComponent component = DaggerMyComponent.create();
For migration purposes, weβve added a temporary javac flag that can be used to re-enable the legacy behavior (the flag is disabled by default).
-Adagger.generatedClassExtendsComponent=ENABLED
This flag will be removed in a future version of Dagger.
Whatβs new in Hilt
Bug fixes
- Fix two issues (e3d4468):
matchingFallbacks
being ignored work with Hilt.- Hilt causing jetifier to execute twice.
- Allow Hilt view constructor to contain non-declared types. (dc76e82)
- Fix #3222. Generated fragment code previously would cause a Lint issue around
LayoutInflater.from()
. (850fc84) - Fix #3329 where modules in a package with non-standard capitalization could cause an error in the Hilt Gradle Plugin. (029fe57 and 329915f)
Dagger 2.41
Whatβs New In Dagger
Potentially Breaking Changes
-
This release fixes a recently noticed, but long-standing bug (#3136) where Daggerβs processors may silently miss a scope/qualifier on a binding if the scope/qualifier annotation is unresolvable (i.e. it is not on the classpath).
Dagger will now prefer to fail the build if there are any unresolvable annotations present where a scope/qualifier is allowed. While Dagger does its best to avoid failing the build for non-scope/qualifier annotations, in general itβs not possible to tell if an annotation is a scope/qualifier unless its type is resolvable -- thus, Dagger may fail on non-scope/qualifier annotations as well.
If these changes break your build, we recommend first trying to fix the breakage by adding the appropriate missing dependencies to your build (in most cases the error message should tell you exactly what type is missing). Although not recommended, you can revert back to the old behavior using the compiler option-Adagger.strictSuperficialValidation=DISABLED
; however, this option will be removed in a future release. If the breakage is specifically due to the validation of transitive component dependencies, you may choose to disable that validation using-Adagger.validateTransitiveComponentDependencies=DISABLED
. If the breakage is specifically due toandroidx.hilt:hilt-lifecycle-viewmodel
you will need to migrate to the native Hilt API (see #3257 (comment)). -
This release fixes an accidental regression (introduced in Dagger version 2.39) that allowed requesting a raw
@Inject
constructor type which was previously not allowed (a61aa50).
We expect breakages due to this issue to be relatively rare and easy to fix -- just replace the raw type with the proper parameterized type. -
The string format of bindings has changed slightly (just spacing). SPI plugins that depend on this format may break. Note that as KSP migrations go forward, other string formats may change slightly in similar ways as well.
New Changes
-
Dagger error messages for unresolvable deferred types have been improved. Error messages now tell you exactly which type could not be resolved and where it was found. Fixes #ββ2208 (727068f), Fixes #3133 (78646fb)
-
Dagger now supports reading the
jakarta.inject
versions ofInject
,Scope
,Qualifier
, andSingleton
. Dagger currently does not supportjakarta.inject.Provider
. Also, code generated by Dagger (and Hilt) continue to use thejavax.inject
symbols. Further changes and support to come in future releases. (2195513)
Bug Fixes
- Updates dagger-lint to avoid displaying a warning due to missing Vendor information. (cb33cc5)
- Fixes an issue where Dagger's lint checks wouldn't work with lint 30.2.x-alpha due to using a removed API. (33ba899)
- Fix #3069 where a class named "Create" could cause a conflict with the create() method on a component. (5ba04fb)
- Fix #3143 where a crash about a missing shard would occur when a members injection binding exists in a parent component. (3545f01)
- Fix #3091. Update MapKey error message to reference new auto-value artifacts. (91e7df1)
Whatβs New In Hilt
New Changes
-
The Hilt Gradle Plugin now supports the updated Gradle plugins DSL as described in https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block via its new id:
com.google.dagger.hilt.android
. (e50aa06) -
There is now a new
@CustomInject
annotation to control when field injection occurs in an@HiltAndroidApp
application class. See https://dagger.dev/hilt/custom-inject for details. (36c17bb)
Bug Fixes
- Fix an issue where Hilt transform was not correctly updating the Signature attribute of an
@AndroidEntryPoint
whose superclass contained a type variable. (475cc05) - Fixes #3119: Added kotlin-stdlib to pom dependencies to avoid breaking java-only projects. (3ec422e)
- Support AGP 7.2 ASM API changes (5502cd7)
Dagger 2.40.5
Dagger bug fixes
- Fixes #3090. Fixes an issue where the superficial validation for inject types was validating deeper than necessary and triggering failures when some classes were not available in the compile classpath.
Dagger 2.40.4
Dagger 2.40.3
Dagger bug fixes
- Fixes #3065: Fixes an issue caused by our XProcessing migration (to support KSP). For now, weβve replaced all problematic usages of XElement#getName() with XElements#getSimpleName(XElement) which ensures we use the old javac simple name.
Dagger 2.40.2
Dagger Bug Fixes
- Fix #2997, #3032: Fixed issue with @BindsInstance parameters when bound types are from compiled dependencies. (ec1a98c).
Hilt New features
- Add convenient overloads for Kotlin users of EntryPointAccessors (6e1f0ea)
- @AliasOf now accepts multiple scope annotations. (aa92b9e)
Hilt Bug Fixes
Dagger 2.40.1
Dagger 2.40
Whatβs New in Hilt
New Changes
- Flip the runtime flag default so that the fix is off and remove the compiler option for the
Fragment.getContext()
fix to make it easier to roll out the fix. This does not change the current default behavior of having the fix be off. (1c24b97, e61ff72) - Turn ON
enableAggregatingTask
by default in Hilt (90ea6a6)
Bug fixes