Skip to content

Releases: google/dagger

Dagger 2.30.1

24 Nov 00:48
Compare
Choose a tag to compare

Bug fixes

  • Sets the default value for experimentalDaggerErrorMessages back to disabled since it breaks hyperlinks in AndroidStudio (6a8bbbf) . Note that this reverses the change to the default value made in the release 2.30.
  • Fixes #2190: Dagger was unnecessarily inspecting all fields of a class and attempting to find their Kotlin metadata, which sometimes led to crashing the processor. Now, Dagger inspects the Kotlin metadata lazily, and only on the fields that require it. (a885c85)

Dagger 2.30

20 Nov 18:37
Compare
Choose a tag to compare

What’s new

Hilt

Hilt has deprecated ApplicationComponent (6313cbd), 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 (802882d). For example:

// Before
@BindValue @JvmField val bindStr = "STRING_BINDING"

// Now
@BindValue val bindStr = "STRING_BINDING"

Dagger

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.

Bug Fixes

  • [Dagger]: Fixes a Dagger compiler crash that occurred when an @Inject was placed in a Kotlin object class. (0816c43)
  • [Hilt]: Fixes #2156: Update Dagger's androidx dependencies to the latest stable versions. (deff5e5)
  • [Hilt]: Fixes suppress deprecation warning in Hilt generated Fragment class. (0a463eb)
  • [Hilt]: Removes Hilt's dependency on jsr250 for @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.

Dagger 2.29.1

10 Sep 20:14
Compare
Choose a tag to compare

What’s New

Hilt

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
}

Dagger:

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.

Potential breaking changes

  • Fix an issue where in some cases missing bindings may have been missed during validation. This issue also affects the binding graph that SPI plugins receive so this fix may cause changes where a previously incorrect binding graph was being supplied. (08193ad)

Bug Fixes

  • Fix #1955, #2065: Hilt would incorrectly try to transform native methods on classes annotated with @AndroidEntryPoint. (2099bad, 2099bad)
  • Fix #1918: Support BroadcastReceiver with @AndroidEntryPoint transform. (ede018b)
  • Fix #1997: Allow Hilt modules to have constructors with params as long as a no-arg constructor exists. (07a7fa9)
  • Fix #2042: Fix bug in OriginatingElementProcessor and ban @AndroidEntryPoint classes with type parameters. (bee2e9a)
  • Fix #970: Add -Adagger.validateTransitiveComponentDependencies compiler option to prevent validating transitive component dependencies. (6deafc7)
  • Add -Adagger.strictMultibindingValidation compiler option to fix map binding contributions that depend on subcomponent bindings. (fb47e11)
  • Fix issue with @Binds when the impl extends a generated type. (71509b8)
  • Add support for receiving a callback for when the activity retained component will no longer be used and destroyed. (6300d02, 218df98)
  • Throw when a race is detected adding a OnClearedListener. (7cf8b11)
  • Reduce constant pool usage by renaming private methods (4a31157)

Dagger 2.29

10 Sep 00:16
Compare
Choose a tag to compare

Do not depend on this release

Depend on release 2.29.1 instead, which fixes issue #2086.

Dagger 2.28.3

17 Jul 22:07
Compare
Choose a tag to compare

Bug fixes

Hilt

  • Fix #1987: Fixes a bug in version 2.28.2 that occurs when a transitive dependency installs something into ApplicationComponent and depends on a version of Hilt less than 2.28.2. (667a8e2)

Dagger 2.28.2

15 Jul 21:32
Compare
Choose a tag to compare

What’s new

Hilt

The Hilt class dagger.hilt.android.components.ApplicationComponent is being renamed to dagger.hilt.components.SingletonComponent. This release adds the new SingletonComponent class in preparation for this change without removing the existing ApplicationComponent. This rename is part of a plan to address #1908 to allow usage of Hilt in non-Android Gradle modules when installing into the SingletonComponent. Current users can begin switching to the new SingletonComponent name as of this release. A future release will remove ApplicationComponent.

Bug fixes

Hilt

  • Fix #1980: Added missing FIELD target to @ActivityContext qualifier. (29e080f)
  • Fix #1909: Update Dagger's JavaPoet dependency to 1.13.0 containing fixes for Dagger & Hilt related to generating code with overriding methods without annotations. (c5de4ab)
  • Fix #1955: Fixes issue with bytecode transformation in Gradle plugin to allow @androidentrypoint annotations to be used with abstract classes containing abstract methods. (884fee5)
  • Fix #1947: Fixes issue with Hilt base classes that extend other Hilt base classes. (61c5c43)
  • Fix #1917: Fixes Hilt example app for Gradle users on mac. (5b3a966)

Dagger 2.28.1

19 Jun 00:47
Compare
Choose a tag to compare

What's New

New Bazel helper macros for using Dagger. See the updated README for instructions. There are also examples using these macros for Dagger and Hilt (9494f40).

Bug fixes

Hilt

  • Throws an error when @androidentrypoint base classes use default params in Kotlin. This is a temporary stopgap while support is investigated (2d43349).
  • Fixes #1910: Allow usage of an @androidentrypoint class having an @androidentrypoint base class when using the gradle plugin (3a31bf6).
  • Fixes #1864: Add minSdkVersion to Lint AndroidManifest.xml. This fixes problems of incorrect added permissions to the manifest (85f285c).

Dagger 2.28

10 Jun 17:47
Compare
Choose a tag to compare

What's New

Hilt Alpha Release

Hilt is a new library that layers on top of Dagger and provides a standard way to incorporate Dagger into an Android application. For more information, see https://dagger.dev/hilt.

Lint checks in Dagger for Kotlin (2597f5a)

Dagger now includes Lint checks for Kotlin users. The checks cover the following cases:

  • Using a redundant field: site target in injected properties
  • Using a redundant @JvmStatic in object modules.
  • Annotating companion objects with @Module (@Module should just be on the enclosing class)

These checks are included by default for users of dagger-android and hilt-android. For Kotlin only projects the checks are available in a new artifact, com.google.dagger:dagger-lint:<version> and can be applied via the lintChecks configuration in Gradle:

apply plugin: "com.android.lint"

dependencies {
  lintChecks "com.google.dagger:dagger-lint:<version>"
}

Bug Fixes

  • Fixes #1812: Fix deploy script for Mac by updating bazel-common containing a fix in the jarjar macro. (11c86ec)
  • Fixes #1693: Gracefully handle @kotlin.Metadata produced by Kotlin compiler versions earlier than 1.3. (477d052)
  • Fixes #1805: Add custom lint checks to Dagger (2597f5a)
  • Fixes #1769: Minor fixes to error messages (8e29da2)

Dagger 2.27

13 Mar 21:58
Compare
Choose a tag to compare

What's New

  1. Fix #955: No longer generate MembersInjectors for types without local injection sites. (20f6442)
  2. Fix #1414: Allow multiple scoped component dependencies (113c498)
  3. Fix #1734: Add support constructor with content layout id for AndroidX (22b2726)
  4. Fix #1740: Remove a usage of Guava API not available in the '-android' variant in case of processor classpath conflicts. (bfb87d5)
  5. Fix #1665: Add an explicit check for member injection of Kotlin object classes rather than crashing. (550d696)
  6. Fix: #1612: Fix duplicate binding errors when a component dependency has the same method defined multiple times via multiple interfaces (0bb69e9)

Experimental Error Message Format

This release includes a flag for using the new experimental error message format. The format and some content of error messages will be changed with this flag in order to improve readability. Please leave feedback on issue #1769. Pending feedback, this format will eventually become the default and replace current error messages.

To opt-in to the new format use -Adagger.experimentalDaggerErrorMessages=enabled.

Currently, this flag:

  • Shortens all class names to the simple class name. A legend is output at the bottom of the errors to map short names to fully qualified names.
  • Reports errors as a single error for each root component.
  • Adds color to error tags to visibly separate individual errors
  • Reduces some extraneous information from some messages.

Dagger 2.26

30 Jan 00:35
Compare
Choose a tag to compare

What's new

  1. Fix #1700: Remove usages of non-Android Guava APIs. (0925e8f)
  2. Fix #1720: Fix incremental dagger-android-processor in kapt when using dagger.android.experimentalUseStringKeys. (6a0ce58)
  3. Fix #1721: Migrate dagger-android to AndroidX. (f45213e)
  4. Better support for binding declarations within Kotlin companion objects of @Module annotated classes. (8190c7c)

Known breaking changes

Companion object modules are no longer allowed on Component#modules list (8190c7c)

It is now an error to add an @Module annotated companion object class to Component#modules (or Subcomponent#modules) list. Instead, only the outer class should be added to the module list.

// Only add this class to the Component#modules list.
@Module
abstract class FooModule {
  @Binds abstract fun bindFoo(impl: FooImpl): Foo

  // @Module is no longer needed here!
  companion object {
    // @JvmStatic is no longer needed here!
    @Provides fun provideBar(): Bar = Bar()
  }
}

Note: For backwards compatibility, we still allow @Module on the companion object and @JvmStatic on the provides methods. However, @Module on the companion object is now a no-op and all of its attributes (e.g. "includes") will be ignored. In future releases, we will make it an error to use @Module on a companion object.

Dagger Android artifacts now use Androidx (f45213e)

The following artifacts have been migrated from the support library to AndroidX:

  • com.google.dagger:dagger-android:2.26
  • com.google.dagger:dagger-android-support:2.26

This change may break users who have not already migrated to AndroidX. The fix is to either migrate your app to AndroidX, or switch back to the support library artifacts which are now available at:

  • com.google.dagger:dagger-android-legacy:2.26
  • com.google.dagger:dagger-android-support-legacy:2.26