github google/dagger dagger-2.29.1
Dagger 2.29.1

latest releases: dagger-2.51.1, dagger-2.51, dagger-2.50...
3 years ago

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)

Don't miss a new dagger release

NewReleases is sending notifications on new releases.