Skip to content

Releases: google/dagger

Dagger 2.56.2

16 Apr 21:09
Compare
Choose a tag to compare

Bug fixes

  • [Dagger] Fixes #4676: Fixes IndexOutOfBoundException when returning suspend from @Provides method. (5d59aed)
  • [Dagger] Fixes #4658: Fixes NoSuchMethodError due to incorrect Guava runtime (Dagger’s Guava version is now temporarily pinned to 33.0.0 to avoid the issue). (9fc3df4)

Dagger 2.56.1

25 Mar 20:33
Compare
Choose a tag to compare

Bug fixes

  • [Dagger] Fixed #4624: Shade Dagger's javapoet-kotlinpoet dependency.

Dagger 2.56

19 Mar 20:16
Compare
Choose a tag to compare

Notable/breaking changes

  • [Jakarta support] Remove deprecated Factory create methods that take a 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. (3412e6c)
  • [Jakarta support] Disallow providing or injecting dagger.internal.Provider. Also disallow injections of raw Provider in Maps, for both javax and dagger Providers. (962bb33)
  • [Dagger]: Usages of @Multibinds and @ElementsIntoSet in Kotlin sources must now use Set/Map from the kotlin.collections package rather than the java.util package.

Bug fixes

  • [Jakarta support] Add support for Jakarta annotations to Hilt. (9001b55)
  • [Jakarta support] Fixed #4572. Fix issue with jakarta.inject.Provider support where in certain cases requests for a Map<K, Provider<V>> would fail to compile. (f4e8003)
  • [Dagger] Remove private modifier from fields/methods within generated Dagger component's private implementation classes (see #4544). (79f8633)
  • [Hilt] Partially Fixed #4423: Fix project isolation violation when checking that Hilt libraries are applied along the Gradle plugin. (91450da)
  • Kotlin was upgraded to 2.1.10 to support KSP 2.1.10-1.0.31. This breaks compatibility older Gradle versions (8.10.2 or below). pre-compiled script plugins (included builds) using Hilt Gradle Plugin will fail to compile.

Dagger 2.55

09 Jan 21:17
Compare
Choose a tag to compare

Notable/breaking changes

  • Added support for injecting 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. (caa7e17)
  • Fixed a number of binding graph related issues.
    These fixes can be enabled with, -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.

Bug fixes

  • Fixed #4549: Fixed incremental processing for LazyClassKey proguard files by adding the
    originating element to the writeResource call. (98a0275)

Dagger 2.54

20 Dec 19:31
Compare
Choose a tag to compare

Bug fixes

  • Fixed #4303: Upgrade Hilt Gradle Plugin to support KSP2 configuration. (76b5819)
  • Fixed #4544: Removes private from InstanceHolder field to avoid unnecessary accessor method. (07d8f88)
  • Fixed #4533: Fixes path separator for Windows when creating LazyClassKey proguard file. (efa421a)

Notable changes

  • In preparation for jakarta support, Dagger’s generated factories now include a 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. (d60729d)

Dagger 2.53.1

09 Dec 18:10
Compare
Choose a tag to compare

Bug fixes

  • Fixes #4525: Update kotlin-jvm-metadata to 2.0.21 to remove dependency on Beta version. (84d3aa5)
  • Fixes #4526: Add the originating element in LazyMapKeyProxyGenerator. (5fd8ec1)

Dagger 2.53

02 Dec 22:22
Compare
Choose a tag to compare

Potentially breaking changes:

@Binds methods now requires explicit nullability

New: @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.
(4941926)

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?
}

Scopes are now banned on @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. (03b237f)

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.

Remove support for Java 7

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).

Other changes

  • Merge pull request #4459: Permit @Multibinds with values
    that are also allowed by @IntoSet/@IntoMap. (0f936b5)
  • Restrict multibindings from providing framework types that conflict with multibinding types
    Dagger provides (e.g. @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. (15a30ca)
  • Remove the ignorePrivateAndStaticInjectionForComponent compiler option.
    This compiler option is only intended for internal testing of the tck tests, and should not be
    used by clients. (dfcdc9c)
  • Upgrade Hilt Gradle Plugin min AGP version to 8.1 (18d2b26)
  • Upgrade Kotlin Metadata dependency to 2.0.0-Beta5 (9a94d19)
  • Fixes #4391: Fix gwt issue (af62f2d)
  • Add GWT dependencies for Jakarta Inject (bea926c)

Dagger 2.52

05 Aug 18:35
Compare
Choose a tag to compare

Dagger 2.52

Notes:
Dagger KSP now requires at least KSP 1.9.24-1.0.20.

Bug fixes

  • Fixed #4302: Suppress deprecation warnings in generated code. (f41033c)
  • Fixed #4323: Added rules to stop LazyClassKey referenced classes being merged with R8 (81512af).
  • Fixed #4345: Fixes intersection type bounds order in generated factories when using KSP (aosp/3164197).
  • Fixed #4352: Fixes an issue where the parameter name "instance" could conflict with fields of the same name in the component. (952c250)
  • Merged pull request #4305: Skip view injection when in edit mode for previews. (65b74f8)
  • Fixed an issue where base classes with a package private constructor would cause the generated code to fail (db25237)
  • Add a jakarta.inject.Provider runtime dependency in preparation for supporting Jakarta Providers (a8581e0)

Dagger 2.51.1

29 Mar 18:57
Compare
Choose a tag to compare

New Dagger Features

  • Added BindingGraphPlugin#onProcessingRoundBegin for pre-processing initialization. (2a6a0b4)

Dagger bug fixes

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.

Dagger 2.51

28 Feb 22:07
Compare
Choose a tag to compare

New Dagger Features

  • Added a @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

Potential breaking changes

  • Protected fields using @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.(408431a)

New Hilt Features

  • Fixed #3197: Used the new @LazyClassKey Dagger feature to remove the keep rule for @HiltViewModel class names. This allows obfuscation of @HiltViewModel annotated ViewModel class names with R8. (0786d0a)
  • Added @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. (c40811e)

Dagger bug fixes

  • Improve Dagger MissingBinding error messages to give more information and be more consistent. (c872238)
  • Fixed #4201: Suppress warning for casting in Dagger generated code. (813ffce)
  • Fixed #4203: Removes @Deprecated annotation causing warnings (3cbc94a)
  • Fixed #4199: Support member injections from type aliased superclass (662d823)
  • Complete Ksp support for Dagger Android: Added a Ksp Processor for Dagger Android ProguardProcessor that was previously missed. The ProguardProcessor is a Dagger Android implementation detail that makes sure the AndroidInjector works correctly when shrinking tools obfuscate @ContributesAndroidInjector annotated injector class names. (e71de27)