Skip to content

Releases: google/dagger

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)

Dagger 2.48

30 Aug 16:28
Compare
Choose a tag to compare

Dagger 2.48

Dagger/Hilt KSP support

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:

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.

Breaking changes

The dagger.ignoreProvisionKeyWildcards is now enabled by default

This 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 check

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

Top-level @Module / @Inject classes can no longer be private

Top-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 functions

Normally 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 #3990.

Fix: Use the traditional parameter approach rather than extension functions.

The use of abstract var properties are no longer allowed in components

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

Other changes

  • Fixed #3995: Allow kotlin source to use java keywords as parameter names in KSP (2c31d66).
  • Fixed #3991: Fixed error message when there are multiple @Inject + @AssistedInject constructors (9105ee671).
  • Fixed #3992: Fixed crash crash when there are multiple @AssistedInject + @AssistedInject constructors (9105ee671.)
  • Add a better error message when Hilt Gradle Plugin class loader conflicts with KSP's Gradle plugin. (3f7b9b5)

Dagger 2.47

14 Jul 00:43
Compare
Choose a tag to compare

What’s new In Dagger

Bug Fixes

  • Update kotlinx-metadata-jvm to 0.6.2 Fixes #3893. (7b16dfd)
  • Disallow private modules in Kotlin sources (already disallowed in Java sources). There is an issue with KAPT where the generated stubs for a private Kotlin module would not be private. To prepare for KSP support where the Kotlin source is read directly, this is fixed to be an error as it should have been. (53fd1a4)

What’s new in Hilt

  • The Hilt Android Gradle plugin will now enforce a minimum Android Gradle plugin (AGP) version of 7.0. (e512d87)
  • Deprecated the enableTransformForLocalTests option in the Hilt Android Gradle plugin. This is no longer necessary as the minimum supported AGP version has been increased to 7.0. (b3fd56f)

Dagger 2.46.1

12 May 21:22
Compare
Choose a tag to compare

What’s new In Dagger

Bug Fixes

  • Fixed #3701: Shade kotlinx metadata in Dagger's artifacts to prevent upstream dependency issues. (d593e01)

Dagger 2.46

28 Apr 21:06
Compare
Choose a tag to compare

What’s new In Dagger

Bug Fixes