Skip to content

Releases: google/dagger

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)

Dagger 2.50

19 Dec 23:57
Compare
Choose a tag to compare

Dagger

Potential breaking changes

  • Introduced a new 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. (75d3cbc)
  • Flip the default for -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. (8372c63)

Bug fixes

  • Fixed the error message for an @Binds @IntoSet implementation with duplicate bindings. (8d01223)

Dagger 2.49

01 Dec 21:04
Compare
Choose a tag to compare

Dagger

New features:

  • Fixed #4044: Add support for KSP with dagger.android (8327177).

Potential breaking changes:

  • Dagger’s generated component no longer contains deprecated no-op module setter methods for modules that have only static/abstract @Provides/@Binds methods (ed47d4b).

    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.

Bug fixes:

  • Fixed #4046, #4140: Fixes Unexpected element error in when calculating nullability (4593c0a)
  • Fixed #4096: Fix type names for inline types on the KSP side (aosp/2789273)
  • Build-time performance improvements (85e9ff1) and (d9d0a8e).
  • Fixed #4060: Updated KSP to 1.9.20-1.0.14 which should contain the fix for a number of incremental processing issues related to KSP (692015f).

Hilt

New features:

  • Fixed #2287, #3523: Add support for using @AssistedInject with @HiltViewModel. (8327177).
    For more details visit https://dagger.dev/hilt/view-model#assisted-injection.
  • Hilt now provides @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.

Bug fixes:

Dagger 2.48.1

03 Oct 22:15
Compare
Choose a tag to compare

Bug Fixes

Fixes #4063, #4054: [KSP]: Fixes some incremental processing issues with KSP (c8a568956)
Fixes #4046: [KSP] Fixes "Unexpected element" in XProcessing library (androidx/androidx@bdc1bb0)
Fixes #4059: [KSP] Align behavior of generic inline types in KSP with KAPT in XProcessing library (androidx/androidx@b0fa9cf)
Fixes #3980: Fixes Lint crash with AGP 8.1.0. (e651294)
Fixes #4055: Fixes issue with using generic types in Dagger's ClassKey (9852b42)