NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Maven Central
Maven Central, #668 by repository stars
A fast dependency injector for Android and Java.
Latest stable
2.60.1
Last release 4 months ago
06 Jul 2026
Release timing varies
gaps range from 1 weeks to 4 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
108 releases · first in 2015
Drag across the ruler to compare, or tap a release to open it.
Fixes #5203: Fixes regression in Dagger 2.60 where the Hilt compiler options (like fastInit) failed to propagate to the Hilt aggregation compilation t
@CanIgnoreReturnValue import error by removing the annotation from ActivityRetainedComponentBuilder (3f2dd8fba)Your coding agent can read these notes before it upgrades. Set up the MCP server →
Fixes #5165 : Support nullable type annotations when using the flag -Adagger.nullableTypeAnnotations=enabled . For more details see https://dagger.dev
-Adagger.nullableTypeAnnotations=enabled.-Pdagger.hilt.fastInit=false. For more details see https://dagger.dev/hilt/flags#fast-init. (0f7642b)@Binds methods to explicitly bind @Inject constructors. For more details see https://dagger.dev/dev-guide/#parameterless-binds. (4c81e94)-Adagger.mapMultibindingDuplicateDetectionFix=ENABLED. This option is DISABLED by default to maintain backward compatibility. See Compiler Options for more details. (504397e)-Adagger.nullableTypeAnnotations=enabled.
For more details see https://dagger.dev/dev-guide/compiler-options#nullable-type-annotations. (4bedb4b64)-Pdagger.hilt.fastInit=false. For more details see https://dagger.dev/hilt/flags#fast-init. (0f7642ba1)@Binds methods to explicitly bind @Inject constructors. For more details see https://dagger.dev/dev-guide/#parameterless-binds. (4c81e9416)-Adagger.mapMultibindingDuplicateDetectionFix=ENABLED. This option is DISABLED by default to maintain backward compatibility. See Compiler Options for more details. (504397ebe)Fixed #5116 , #5099 : Replaced Hilt's "android-classes" transform with attribute rules
Fixed #5099 : Fixes compilation error with jetifierEnabled=true in AGP 9
jetifierEnabled=true in AGP 9 (8dcce8790)(If you do not use Hilt or the Hilt Gradle plugin, this change does not affect you.)
(If you do not use Hilt or the Hilt Gradle plugin, this change does not affect you.)
This release adds AGP 9 support for the Hilt Gradle plugin. This means that if you use the Hilt Gradle Plugin, AGP 9 is now a requirement along with AGP 9’s own requirements like Gradle 9.1+ (https://developer.android.com/build/releases/agp-9-0-0-release-notes).
Note: AGP 9 also seems to cause issues with enableJetifier=true (see #5099). This will be fixed in a follow-up release.
Fixes #3601 . No longer adds a deprecation warning for unused dependencies on setters on the component builder.
Note: AGP 9 support was held back from this release (0a5b42c) because it forces users onto AGP 9. It will be available in the next Dagger release (e92e3f3).
dagger.useBindingGraphFix to enabled (d41e836).@Provides so that it is installed into the correct component (e.g. the ActivityComponent instead of SingletonComponent). You can also set dagger.useBindingGraphFix=disabled but note that this flag is only temporary and will eventually be removed.abstract var in components is now banned in super types.abstract var property creates both a getter and a setter on the component which is almost always unintentional.abstract val foo: Foo if you need a getter or abstract fun inject(foo: Foo) if you need an inject method. Note that abstract var is already banned if it is declared directly on the @Component class/interface, but this change fixes the check so that it’s banned even if it’s inherited from a super type.Fixed #4847 : Fixed an issue with the Hilt Gradle Plugin registered transforms on projects using Gradle 9.0.0
Fixes #4734 : Updated Hilt's Gradle Plugin detection of AGP to maximize compatibility and avoid the confusing 'The Hilt Android Gradle plugin can only
The generated Factory / MembersInjector constructors have changed from public to private. This shouldn’t affect most users since these classes are onl
The generated Factory/MembersInjector constructors have changed from public to private. This shouldn’t affect most users since these classes are only meant to be called by Dagger’s other generated code. If you do happen to be broken by this change, you should avoid calling Dagger’s generated Factory/MembersInjector classes directly. For a temporary solution, you can also switch to using the public static methods to create an instance. (165cf20)
Fixes #4779. Unshades the Kotlinx Metadata to support Kotlin 2.2.0 (bfa88b9)
[Dagger] Fixes #4676 : Fixes IndexOutOfBoundException when returning suspend from @Provides method.
IndexOutOfBoundException when returning suspend from @Provides method. (5d59aedd1)NoSuchMethodError due to incorrect Guava runtime (Dagger’s Guava version is now temporarily pinned to 33.0.0 to avoid the issue). (9fc3df48e)[Dagger] Fixed #4624: Shade Dagger's javapoet-kotlinpoet dependency.
[Jakarta support] Remove deprecated Factory create methods that take a javax.inject.Provider. This means components built with an older Dagger version…
javax.inject.Provider. This means components built with an older Dagger version but with factory dependencies from a newer Dagger version will no longer compile. If you run into this, the Dagger version compiling the component must be upgraded. (3412e6c03)dagger.internal.Provider. Also disallow injections of raw Provider in Maps, for both javax and dagger Providers. (962bb3335)@Multibinds and @ElementsIntoSet in Kotlin sources must now use Set/Map from the kotlin.collections package rather than the java.util package.jakarta.inject.Provider support where in certain cases requests for a Map<K, Provider<V>> would fail to compile. (f4e80036f)This should be usable anywhere javax.inject.Provider is usable. Note that this technically comes with a breaking change to disallow providing jakarta.…
jakarta.inject.Provider. This should be usable anywhere javax.inject.Provider is usable. Note that this technically comes with a breaking change to disallow providing jakarta.inject.Provider types in the same way it is disallowed for javax.inject.Provider. (caa7e178b)-Adagger.useBindingGraphFix=ENABLED, but due to this sometimes being a breaking change we’ve set the default behavior to “disabled” for now. We will flip the default to “enabled” in a future release, and eventually remove the flag altogether. Enabling this feature can fix a number of confusing error messages. See https://dagger.dev/dev-guide/compiler-options#useBindingGraphFix for more details.writeResource call. (98a027541)Fixed #4303: Upgrade Hilt Gradle Plugin to support KSP2 configuration.
create() method that uses dagger.internal.Provider rather than javax.inject.Provider. For now, the javax.inject.Provider create() method is also kept for compatibility, but it will be removed in a future release. When that happens, libraries built with the newer version of Dagger may break downstream users of @Component that are built with an older version of Dagger. (d60729d20)Fixes #4525: Update kotlin-jvm-metadata to 2.0.21 to remove dependency on Beta version.
@Provides @IntoMap Provider ). This is technically a breaking change but existing issues should either be for unused code or code that should have alr…
@Binds methods now requires explicit nullabilityNew: @Binds methods must explicitly declare nullability (previously we tried to infer it from
the parameter). This change aligns the nullability behavior of @Binds with how nullability is
treated elsewhere in Dagger by requiring it to be explict at the request and declaration sites.
(4941926c5)
Suggested fix: If you get a failure due to this change, add the proper nullability to your @Binds method/parameter. For example:
@Module
interface MyModule {
- @Binds fun bindToNullableImpl(impl: FooImpl): Foo
+ @Binds fun bindToNullableImpl(impl: FooImpl?): Foo?
}
@Binds that delegate to production implementations.New: Scoping an @Binds method that delegates to an @Produces implementation is not
allowed. The scope was ignored anyway because production bindings are implicitly scoped. (03b237ff2)
Suggested fix: Remove the scope annotation (since the scope was ignored, this should not be a functional change).
@Module
interface MyModule {
- @ProductionScoped
@Binds fun bindToProductionImpl(impl: FooImpl): Foo
}
@JvmSuppressWildcards now required on multibound map requests in KSP.New: When requesting a multibound map, users must include @JvmSuppressWildcards on the
map's value, e.g. Map<K, @JvmSuppressWildcards V>. Note that this has always been the behavior
in KAPT, but due to a bug in the KSP implementation we accidentally matched the request without
@JvmSuppressWildcards.
Suggested fix: Unfortunately, this means users may need to add back @JvmSuppressWildcards
for multibound map requests. At the moment, KSP doesn't provide a way to determine the Kotlin type
is actually assignable to Map<K, V> without @JvmSuppressWildcards at compile time, and without
this check users could hit runtime failures when Dagger tries to cast the type to the users type.
class MyClass
@Inject constructor(
- multiboundMap: Map<K, V>
+ multiboundMap: Map<K, @JvmSuppressWildcards V>
)
In the future, we may consider simple cases where we can guarantee that @JvmSuppressWildcards can
be elided, but that is out of scope for this release.
New: Dagger has officially removed support for Java 7. Oracle ended support for Java 7 in July 2022, and since Dagger has upgraded to JDK 18, compiling with language level 7 is no longer supported. Note that this may not break users immediately since Dagger's generated code is still technically Java 7 compatible.
Suggested Fix: Upgrade to Java 8+ (While Dagger can still test Java 8 at the moment, it is also deprecated as of January 2024, and we'll likely need to remove support soon).
@Multibinds with values
that are also allowed by @IntoSet/@IntoMap. (0f936b5ce)@Provides @IntoMap Provider<String>). This is technically a breaking
change but existing issues should either be for unused code or code that should have already
broken anyway. (15a30ca15)ignorePrivateAndStaticInjectionForComponent compiler option.
This compiler option is only intended for internal testing of the tck tests, and should not be
used by clients. (dfcdc9ccb)Fixed #4302: Suppress deprecation warnings in generated code.
Dagger 2.52
Notes: Dagger KSP now requires at least KSP 1.9.24-1.0.20.
Added BindingGraphPlugin#onProcessingRoundBegin for pre-processing initialization.
BindingGraphPlugin#onProcessingRoundBegin for pre-processing initialization. (2a6a0b461)Fixed #4181: Associate Dagger Android output with the generated Component, so that incremental builds with Ksp won’t fail.
Fixed #4254: Support using scoped @LazyClassKey map bindings.
Fixed #4262: Support referencing an array of annotations in a map key annotation.
Fixed #4203: Removes @Deprecated annotation causing warnings
@LazyClassKey annotation that supports using class names as a map key. Unlike the existing @ClassKey, the map generated by @LazyClassKey won’t eagerly load all of the classes for the keys. This can be useful in situations or environments where classloading can be expensive, such as on Android. For more information, see https://dagger.dev/dev-guide/multibindings@Inject are now banned in Kotlin classes. This is because Kotlin protected fields are not accessible by code in the same package, unlike Java. This has been working up to this point because Dagger generates Java code, but that is unintentional and would break if Dagger switched to generate Kotlin code.(408431a3b)@LazyClassKey Dagger feature to remove the keep rule for @HiltViewModel class names. This allows obfuscation of @HiltViewModel annotated ViewModel class names with R8. (0786d0af5)@SkipTestInjection which can be used for skipping test injection in Hilt Android tests, which may be useful if building separate custom test infrastructure to inject the test class from another Hilt component. (c40811e71)@Deprecated annotation causing warnings (3cbc94ad3)@ContributesAndroidInjector annotated injector class names. (e71de27a1)Introduced a new dagger.internal.Provider to facilitate future support for jakarta.inject.Provider types. There should be no visible changes at this t
dagger.internal.Provider to facilitate future support for jakarta.inject.Provider types. There should be no visible changes at this time, though with such a large change there is a risk of unanticipated version compatibility issues across libraries built with different Dagger versions. (75d3cbcf9)-Adagger.explicitBindingConflictsWithInject to enabled. This flag fixes a bug where an explicit binding like an @Provides should conflict with @Inject bindings if the @Inject is actually used in a parent component. (8372c6308)@Binds @IntoSet implementation with duplicate bindings. (8d0122322)Dagger’s generated component no longer contains deprecated no-op module setter methods for modules that have only static/abstract @Provides/@Binds met…
dagger.android (832717767).Dagger’s generated component no longer contains deprecated no-op module setter methods for modules that have only static/abstract @Provides/@Binds methods (ed47d4b88).
Note: If you hit this issue, the fix is to remove the call to the setter method in your code. For example:
MyComponent component =
DaggerMyComponent.builder()
- .moduleWithOnlyStaticOrAbstractMethods(new ModuleWithOnlyStaticOrAbstractMethods())
.build();
These setter methods were already no-ops (i.e. Dagger just ignored them), so removing it should not cause any functional changes.
Unexpected element error in when calculating nullability (4593c0a)1.9.20-1.0.14 which should contain the fix for a number of incremental processing issues related to KSP (692015f).@AssistedInject with @HiltViewModel. (8327177).
For more details visit https://dagger.dev/hilt/view-model#assisted-injection.@ActivityRetainedSavedState SavedStateHandle from ActivityRetainedComponent (1cac33b).
Note: This feature relies on a somewhat experimental implementation in order to provide this binding lazily while also avoiding leaking the activity. The laziness is a requirement to not restrict activity injection and also to avoid bloating the saved state when unused. While we predict this should be safe to rely on, if issues are discovered with this implementation, it is possible that a future release may have to remove this binding.FileNotFoundException in AGP 8.3 (6018cd2) and (f946e34).Fixes #4063, #4054: [KSP]: Fixes some incremental processing issues with KSP (c8a568956) Fixes #4046: [KSP] Fixes "Unexpected element" in XProcessing
Fixes #4063, #4054: [KSP]: Fixes some incremental processing issues with KSP (c8a568956) Fixes #4046: [KSP] Fixes "Unexpected element" in XProcessing library (https://github.com/androidx/androidx/commit/bdc1bb06d4f5dbd574bb66cef674ba31846eb4d3) Fixes #4059: [KSP] Align behavior of generic inline types in KSP with KAPT in XProcessing library (https://github.com/androidx/androidx/commit/b0fa9cf493458a1f3b35a1d68298552e3eaae678) Fixes #3980: Fixes Lint crash with AGP 8.1.0. (e651294c2) Fixes #4055: Fixes issue with using generic types in Dagger's ClassKey (9852b4237)
There are also a few potentially breaking changes included with this release. These changes were made to better support Dagger usage with Kotlin sourc…
Dagger 2.48 includes the alpha release of the Dagger and Hilt KSP processors.
Instructions for using the Dagger/Hilt KSP processors can be found at https://dagger.dev/dev-guide/ksp.
In order to use Dagger’s KSP processor you will need to:
kapt to ksp (see https://dagger.dev/dev-guide/ksp#setup).kapt processors that generate classes that need to interact with Dagger (see https://dagger.dev/dev-guide/ksp#interaction-with-javackapt-processors).If you depend on androidx.hilt:hilt-common or androidx.hilt:hilt-work they will need to be updated to at least 1.1.0-alpha01.
Also note that Dagger’s KSP processors are still in the alpha stage. So far we’ve focused mainly on trying to ensure correctness rather than optimize performance. Please apply due diligence when enabling ksp and report any bugs or performance issues at https://github.com/google/dagger/issues. The current list of known issues can be found here.
There are also a few potentially breaking changes included with this release. These changes were made to better support Dagger usage with Kotlin sources, and make the migration from KAPT to KSP more seamless. We don’t expect these changes to affect most users. Please see below for more details.
dagger.ignoreProvisionKeyWildcards is now enabled by defaultThis may break apps that are providing the same binding with different wildcards, e.g. Foo<Bar> and Foo<? extends Bar>.
Fix: See https://dagger.dev/dev-guide/compiler-options#ignore-provision-key-wildcards for suggestions on how to fix this. If fixing is not an immediate option, you can still disable the flag with dagger.ignoreProvisionKeyWildcards=DISABLED.
@Binds assignability checkUnlike KAPT, KSP takes nullability into account when checking if a type is assignable to another type. This changes the behavior of Dagger’s @Binds usage validation such that a type that was assignable in KAPT may no longer be assignable in KSP. For example:
// Incorrect: this compiles successfully in KAPT but the compilation fails in KSP
@Binds fun bind(impl: FooImpl<Bar?>): Foo<Bar>
Fix: To fix this breakage, users should update the parameter or return type in the method such that they are actually assignable when taking nullability into account. For example:
// Correct: this compiles successfully in KAPT and KSP
@Binds fun bind(impl: FooImpl<Bar?>): Foo<Bar?>
@Module / @Inject classes can no longer be privateTop-level @Module or @Inject classes can no longer be private. This was previously allowed purely by accident (rather than being an officially supported feature) due to the way Kotlin’s private classes are represented as package-private in KAPT’s generated java stubs.
Fix: Replace the private visibility modifier with internal or public.
@Binds and @Provides methods can no longer be extension functionsNormally when we define an @Provides/@Binds function we put the dependencies in the parameter list:
@Module
abstract class BarModule {
@Binds
abstract fun bindsBar(@Marker foo: Foo): Bar
}
However, since the introduction of KAPT, it was also technically possible to define an @Provides/@Binds function using an extension function:
@Module
abstract class BarModule {
@Binds
abstract fun @receiver:Marker Foo.bindsBar(): Bar
}
This extension function syntax worked more by coincidence (rather than being an officially supported feature) due to the way extension functions are represented in KAPT’s generated java stubs. After review, we’ve decided not to support this feature anymore in KAPT or KSP. See more at https://github.com/google/dagger/issues/3990.
Fix: Use the traditional parameter approach rather than extension functions.
abstract var properties are no longer allowed in componentsA var property adds both a getter (aka request) method and a setter (aka injection) method for a binding. However, the setter method typically goes unused since there is rarely a case for needing both methods for a single binding. After discussion within the team, we’ve decided to ban abstract var properties in components.
Fix: Use fun (or val) for getter methods, use fun for setter methods.
@Inject + @AssistedInject constructors (9105ee671).@AssistedInject + @AssistedInject constructors (9105ee671.)Deprecated the enableTransformForLocalTests option in the Hilt Android Gradle plugin. This is no longer necessary as the minimum supported AGP version…
dagger.ignoreProvisionKeyWildcards has been added. Enabling this flag will be required to use KSP in a future release. For more information on this flag, see the documentation here: https://dagger.dev/dev-guide/compiler-options#ignore-provision-key-wildcardsenableTransformForLocalTests option in the Hilt Android Gradle plugin. This is no longer necessary as the minimum supported AGP version has been increased to 7.0. (b3fd56f23)Fixed #3701: Shade kotlinx metadata in Dagger's artifacts to prevent upstream dependency issues.
Fixed #3701 and #3838. Updated Dagger to kotlinx metadata 0.6.0.
Fixed an issue where a scoped @Binds used in a cycle would cause an NPE on component creation in fastInit mode.
Dagger 2.45
@Binds used in a cycle would cause an NPE on component creation in fastInit mode. (fae46c713)@Multibinds types incorrectly used framework types like Provider. (f5ad2b29b)@HiltAndroidApp is not used in an app module (ffaa7a6ff)Fixes #3633: Updated shading rules to include newly added classes in androidx.room.compiler to prevent class version conflicts with user dependency on
androidx.room.compiler to prevent class version conflicts with user dependency on Room.Fixes #3619: Upgrades XProcessing jars to get upstream fix for enums in annotations (which were missing fully qualified name or import in generated co
Fixes #3531: Removed formatting from dagger.android generated source could be a breaking change for anyone relying on golden files for Dagger’s genera…
ViewModelLifecycle. This can be injected in the ViewModelComponent and used to register listeners for when ViewModel#onCleared() is called. This change also includes a breaking change for anyone who implemented the ActivityRetainedLifecycle interface themselves. This should be rare though as this interface was not meant to be implemented by users. (55aa4c60a)com.android.test Gradle module. (ea39850c7)Fixes #3495: Updates the XProcessing jars, which should again be compatible with java 8.
Fixes #3480. Replace dependency on javax.annotation:jsr250-api:1.0 with javax.annotation:javax.annotation-api:1.3.2.
javax.annotation:jsr250-api:1.0 with javax.annotation:javax.annotation-api:1.3.2. (e9dc377d1)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 X
getDefaultViewModelProviderFactory() returns null. This is unlikely to happen though unless overridden by the user to return null. (9eee8e47f)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 and androidx.fragment to 1.5.0androidx.lifecycle to 2.5.0androidx.savedstate to 1.2.0enableAggregatingTask) turned on. (b83887624)@HiltViewModel with different keys would cause a crash.@HiltViewModel with navigation backstack entries as the owner. The default ViewModelProvider.Factory from activities and fragments can be used directly with the backstack entry as the owner. (74ea7653a)@BindValueIntoMap in Kotlin code do not need to use the @field notation. (e59183324)…javac bottleneck. However, it may also be a breaking change for some users. For example
As of this release, Dagger’s generated class will no longer extend the user-defined @Component annotated class (885b16dcf). 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.
matchingFallbacks being ignored work with Hilt.LayoutInflater.from(). (850fc8474)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
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 to androidx.hilt:hilt-lifecycle-viewmodel you will need to migrate to the native Hilt API (see https://github.com/google/dagger/issues/3257#issuecomment-1042627102).
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 (a61aa50c8).
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.
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 (727068f38), Fixes #3133 (78646fbe6)
Dagger now supports reading the jakarta.inject versions of Inject, Scope, Qualifier, and Singleton. Dagger currently does not support jakarta.inject.Provider. Also, code generated by Dagger (and Hilt) continue to use the javax.inject symbols. Further changes and support to come in future releases. (219551376)
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. (e50aa067e)
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. (36c17bbff)
@AndroidEntryPoint whose superclass contained a type variable. (475cc0516)Fixes #3090. Fixes an issue where the superficial validation for inject types was validating deeper than necessary and triggering failures when some c
Fix #3075: Fixes an issue where we were not deferring processing for a generated type in Kotlin source
Fix #3075: Fixes an issue where we were not deferring processing for a generated type in Kotlin source (745d30cf2)
Fixes #3065: Fixes an issue caused by our XProcessing migration (to support KSP). For now, we’ve replaced all problematic usages of XElement#getName()
Fix #2997, #3032: Fixed issue with @BindsInstance parameters when bound types are from compiled dependencies. (ec1a98c).
Fix an AGP 7.2 incompatibility issue in the Hilt Gradle Plugin due to AGP breaking their API when cleaning up a deprecated type.
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 th
New Changes
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. (1c24b9718, e61ff7239)enableAggregatingTask by default in Hilt (90ea6a604)Bug fixes
EarlyEntryPoints#get() will now throw if there are no @EarlyEntryPoint annotated interfaces. (b5ef01c04)@OptionalInject activity/fragment classes could not be used with non-Hilt ViewModels. (8ef08fa07)Fix #2834: Hilt processor now checks the correct "names" property when getting values from Kotlin @Suppress annotations.
@Suppress annotations. (db21d3fd1)toImmutableSet to use DaggerStreams rather than Guava. (43a7fe1ba)This may significantly improve test compilation time for large projects, but is a breaking change for some tests due to changed visibility requirement…
shareTestComponents now defaults to true. This may significantly improve test compilation time for large projects, but is a breaking change for some tests due to changed visibility requirements. See Hilt’s flags documentation for details. (7e09cee32)enableAggregatingTask (38db196d7)@Input parameter in ASM transform. (2f5003545)Fix #2784. Fix an issue with AGP 7.0+ where the Gradle plugin bytecode transform was not applied to non-test code. This affected all @AndroidEntryPoin
@AndroidEntryPoint and @HiltAndroidApp classes that did not directly themselves extend from the Hilt-generated base class and meant that Hilt was not actually applied to those classes. (666df50b8)As part of necessary changes in order to eventually support running Dagger as a KSP processor, Dagger now has a dependency on the KSP artifacts. These
As part of necessary changes in order to eventually support running Dagger as a KSP processor, Dagger now has a dependency on the KSP artifacts. These artifacts are available from the Google Maven repository, so this may break users who currently do not use this repository for other dependencies. The Google Maven repository is available at https://maven.google.com.
In your build.gradle file, add google() in repositories.
repositories {
google()
}
Example: https://github.com/google/dagger/blob/ff62b195c1a00727192154a409aa4ab0b796ff07/javatests/artifacts/dagger/simple/build.gradle#L23
If using the repository list from our workspace_defs.bzl, then no change is needed.
Otherwise, pass "https://maven.google.com" to your usage of maven_install.
maven_install(
repositories = [
"https://maven.google.com",
...
],
...
)
Add the repository in your pom.xml file like the following:
<repositories>
<repository>
<id>google-maven</id>
<name>Google Maven Repo</name>
<url>https://maven.google.com</url>
</repository>
</repositories>
Example: https://github.com/google/dagger/blob/ff62b195c1a00727192154a409aa4ab0b796ff07/examples/maven/pom.xml#L20
ClassKey and StringKey) to be placed on fields in order to support Hilt's @BindValueIntoMap. (7af40dfff)This release fixes an incompatibility in the Hilt Gradle Plugin with AGP 7.0-beta04 and 7.1-alpha03. However, with this fix the HiltGradlePlugin will not work with alpha/beta versions of AGP 7.0 and 7.1 older than the versions previously mentioned. This fixes #2700. (be2f89ade)
ClassKey and StringKey) to be placed on fields in order to support Hilt's @BindValueIntoMap. (7af40dfff)enableAggregatingTask would not correctly generate Hilt classes when compiling in a dev environment with Windows OS. (a7c3c9ee5)Fix #1079: Added an automatic module name to the com.google.dagger:dagger artifact to improve Java 9 compatibility.
com.google.dagger:dagger artifact to improve Java 9 compatibility. (cb308856a)com.google.dagger:dagger-android-jarimpl artifact. This was an internal-only artifact, so its removal should not affect users. (6da2e7ea8)There’s a new flag, enableAggregatingTask, supported by the Hilt Gradle plugin that allows Hilt to perform classpath aggregation in a dedicated Gradle task. This allows Hilt’s annotation processors to be “isolating” so that they are only invoked when necessary. This reduces incremental compilation times by reducing how often an incremental change causes a rebuild of the Dagger components. For details on how to enable this flag see https://dagger.dev/hilt/gradle-setup#aggregating-task.
Note that the default for enableAggregatingTask is currently false, but it will be changed to true in an upcoming release, so please try to enable this flag and report any issues.
Also, note that enableAggregatingTask will automatically enable sharing test components, so please read the caveats for enabling that flag as well.
Finally, enableAggregatingTask replaces enableExperimentalClasspathAggregation which will be removed in an upcoming release. Please replace any usages of enableExperimentalClasspathAggregation with enableAggregatingTask.
…don’t trigger the runtime error, this could be a breaking change.
Currently, a Hilt fragment’s getContext() method incorrectly continues to return a context value even after the fragment is removed. This differs from the behavior of a regular fragment. Fixing this is a breaking change that may introduce crashes at runtime if code incorrectly accessed the fragment’s context after removal and relied on Hilt’s incorrect behavior, so a flag has been introduced with the new fixed behavior default off.
Please enable the flag with -Adagger.hilt.android.useFragmentGetContextFix=true to roll out this change at your own discretion. You may choose to, for example, start by enabling this only in development or some small testing population to find errors. In a future release, this flag will be defaulted to true and then in some release after that, the flag will be removed. (5ce0ceadd)
Fix #2577: Adds a flag to disable the cross-compilation root validation that was enabled by default as of version 2.35. (See https://dagger.dev/hilt/c
This means that Hilt is ready for use in production. Thanks for all the feedback through our alpha and beta stages! From now on, Hilt will no longer h
This means that Hilt is ready for use in production. Thanks for all the feedback through our alpha and beta stages! From now on, Hilt will no longer have alpha/beta releases and instead will be released with the same process as Dagger.
@EarlyEntryPoint usage in a library that is built using an older version of Hilt, the @EarlyEntryPoint will no longer be picked up, resulting in a runtime error in tests (production code will be unaffected). To fix, all upstream usages of @EarlyEntryPoint must be built using this version of Hilt or later. (27a28276b)@HiltAndroidApp do not depend on targets with @HiltAndroidTest and vice versa as this can cause confusion with which modules are included in which Dagger components. Hilt version 2.35.1 adds a flag to disable this check.Fix #2070: Fix leak in FragmentContextWrapper by also releasing the inflators, if they exists.
The alpha androidx extension @ViewModelInject is no longer supported. @ViewModelInject has been deprecated since androidx.hilt 1.0.0-alpha03 and was r…
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 (faebc3c66).
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
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 (3778ee2b8)
Users of @ViewModelInject can migrate to @HiltViewModel which was added in Dagger 2.31.
@HiltViewModel annotation to the class@ViewModelInject annotation on the constructor with @Inject.@Assisted from the SavedStateHandle constructor parameter, if it existsandroidx.hilt:hilt-lifecycle-viewmodel dependency from your build.gradle fileinit() method in generated Activity to avoid conflict with user method of same name. (1c66033f5)disableAndroidSuperclassValidation when no Android entry points are in the source module. (c70cf2d38)Fragment reference in FragmentContextWrapper after Fragment#onDestroy() to prevent leaks if a non-Hilt View outlives the Hilt Fragment that created it. (7f4c3a236)Fixes #2370, #2396: Qualified @AssistedInject/@AssistedFactory types can now be provided and injected as normal bindings.
Previously, Hilt has been in Alpha, and it is now officially in Beta. This means that there will be no further changes to the APIs until after Hilt becomes stable. We’ll focus on bug fixes and getting Hilt into a stable release.
(This also means that Hilt artifacts will now be postfixed with -beta instead of -alpha).
Activity injection is now delayed until OnContextAvailableListener to enable member injecting ViewModels with SavedStateHandle. To use the ContextAware APIs androidx.activity, androidx.fragment and androidx.lifecycle dependencies are updated across the Dagger libraries. (623d3a61e)
Note that this affects Hilt base classes that expected its members to be injected due to another Hilt class extending it. This essentially changes the injection of activities to occur within super.onCreate() instead of before super.onCreate().
@AndroidEntryPoint
public class MainActivity extends BaseActivity {
// ...
}
abstract class BaseActivity extends FragmentActivity {
@Inject Foo foo;
@Override
protected void onCreate(Bundle savedInstanceState) {
foo.doSomething(); // <- This will now result in an NPE since ‘foo’ hasn’t been injected yet.
super.onCreate();
}
}
For cases where a binding is strictly needed before super.onCreate() then the base class will have to invoke a Hilt generated method inject(). For example:
abstract class BaseActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
inject(); // <- This will force early injection.
foo.doSomething();
super.onCreate();
}
}
// An inject method to be overridden by the Hilt generated class.
protected void inject() {
throw new UnsupportedOperationException();
}
@Beta here means that this API is not considered stable -- the opposite from how the term is used in the Hilt “beta” release).enableExperimentalClasspathAggregation was turned ON. (b25eab897)Removes the deprecated ApplicationComponent. Note that this will now require upgrading any Androidx Hilt Worker dependencies to version 1.0.0-alpha03.
@AssistedFactory classes that have the same type now require a name to be set via @Assisted("foo") to disambiguate between arguments. Previously, order of parameters was used. Fixes #2281. (44d4f4b85)@AssistedFactory method calls a generated component method with the same name. (e2c9a9a21)@AssistedFactory to allow for creating a parameterized Foo with type parameters specified by the factory. (552f430d2)@AssistedFactory creator method. (9a9015190)delayComponentReady() method on HiltAndroidRule allows deferring component initialization in tests until after test execution has started. This allows modifying @BindValue field values in the case that default component initialization would have otherwise requested them before an @Before or @Test method. (315b1fa30)HiltAndroidRule now enforces that inject() is only called at most once per test case. (5dfd484bf)ApplicationComponent. Note that this will now require upgrading any Androidx Hilt Worker dependencies to version 1.0.0-alpha03. (6592b06b2)enableExperimentalClasspathAggregation turned ON. (53ceb9167, 98c73c619)@InstallIn module referencing a component without a component builder would fail (132d9eab8)Issue #2300: Reverts an unintentional change to Hilt and dagger-android-support that depended on RC versions of AndroidX
public to avoid triggering an existing r8 optimization bug. (7a3d6fb3b)Adds back the deprecated ApplicationComponent since the latest androidx.hilt:hilt-work release still uses it.
androidx.hilt:hilt-work release still uses it. (b9325a45c)@AssistedInject types can now be used as @Assisted parameters (c4d829d61)Adds a new @HiltViewModel feature to Hilt. This replaces the @ViewModelInject AndroidX extension which will be deprecated in a future release. @HiltVi…
Dagger now supports assisted injection. See the docs at https://dagger.dev/dev-guide/assisted-injection (daf0c6613)
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) (d8284724a)
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 (253ac8b34)
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 (d69b00f15)
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 (239768bcc)
The deprecated ApplicationComponent symbol has been removed. Users should migrate to SingletonComponent. This is intended to be a pure rename/functional no-op. (37cb8c842)
Sets the default value for experimentalDaggerErrorMessages back to disabled since it breaks hyperlinks in AndroidStudio (6a8bbbf03) . Note that this r
experimentalDaggerErrorMessages back to disabled since it breaks hyperlinks in AndroidStudio (6a8bbbf03) . Note that this reverses the change to the default value made in the release 2.30.Hilt has deprecated `ApplicationComponent` (6313cbdf2), and it will soon be removed in a future release. Use `SingletonComponent` instead.
Hilt has deprecated ApplicationComponent (6313cbdf2), and it will soon be removed in a future release. Use SingletonComponent instead.
Hilt now supports @BindValue val fields in Kotlin without the use of @JvmField (802882dd4). For example:
// Before
@BindValue @JvmField val bindStr = "STRING_BINDING"
// Now
@BindValue val bindStr = "STRING_BINDING"
Dagger now uses the “experimentalDaggerErrorMessages” by default (See #1769 for more information). The old error message format can still be used by setting -Adagger.experimentalDaggerErrorMessages=disabled as a javacopt.
@Generated. (8dca74b)
Note: Hilt previously depended on jsr250 for the @Generated annotation, but this behavior has now been changed to match Dagger (see #95). Now, Hilt only adds the @Generated annotation only if the Generated class is present in the classpath. Thus, since we’ve now removed the jsr250 dependency from Hilt, the generated code will no longer contain the @Generated annotation by default.The hilt-android-compiler artifact will be deprecated in a future release, so please migrate to hilt-compiler.
Hilt has two new artifacts hilt-core and hilt-compiler that allow Hilt to be used with pure Java/Kotlin libraries within an AndroidApplication (see issue #1908 for the full motivation/discussion).
The hilt-core artifact contains the core (non-Android) Hilt APIs. Note that this artifact is only meant to be used by pure Java/Kotlin libraries within an Android application. Hilt does not currently support non-Android applications or non-Android tests.
The hilt-compiler artifact is just a rename of hilt-android-compiler. The motivation here is to have a single compiler artifact that works with both Android and non-Android libraries. The hilt-android-compiler artifact will be deprecated in a future release, so please migrate to hilt-compiler.
The example below shows which artifacts to use in an Android vs pure Java/Kotlin library.
// Android library deps
dependencies {
implementation "com.google.dagger:hilt-android:2.29-alpha"
androidTestImplementation "com.google.dagger:hilt-android-testing:2.29-alpha"
annotationProcessor "com.google.dagger:hilt-compiler:2.29-alpha" // or kapt
}
// Pure Java/Kotlin library deps
dependencies {
implementation "com.google.dagger:hilt-core:2.29-alpha"
annotationProcessor "com.google.dagger:hilt-compiler:2.29-alpha" // or kapt
}
A new Dagger compiler option was added to allow disabling transitive validation of component dependency, dagger.validateTransitiveComponentDependencies,. The default value for the flag is enabled (same as before). To disable it, add the following to your compiler options: -Adagger.validateTransitiveComponentDependencies=DISABLED. For a full motivation/discussion, see issue #970.
A new Dagger compiler option was added to fix an issue with map binding contributions that depend on subcomponent bindings, dagger.strictMultibindingValidation. The default value for the flag is disabled (same as before). However, we will be enabling this flag in a future release. To check if your application will be affected, you can enable the flag by adding the following to your compiler options: -Adagger.strictMultibindingValidation=ENABLED. See #2085 for details.
@AndroidEntryPoint. (2099bade9, 2099bad)BroadcastReceiver with @AndroidEntryPoint transform. (ede018b7a)OriginatingElementProcessor and ban @AndroidEntryPoint classes with type parameters. (bee2e9a51)-Adagger.validateTransitiveComponentDependencies compiler option to prevent validating transitive component dependencies. (6deafc748)-Adagger.strictMultibindingValidation compiler option to fix map binding contributions that depend on subcomponent bindings. (fb47e1179)@Binds when the impl extends a generated type. (71509b841)Depend on release 2.29.1 instead, which fixes issue #2086.
Do not depend on this release
Depend on release 2.29.1 instead, which fixes issue #2086.
One column per quarter.