Dagger 2 v2.29.1 Release Notes

Release Date: 2020-09-10 // 20 days ago
  • What’s New


    πŸ‘€ 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 depsdependencies { 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 depsdependencies { implementation "com.google.dagger:hilt-core:2.29-alpha" annotationProcessor "com.google.dagger:hilt-compiler:2.29-alpha" // or kapt}


    πŸ‘€ 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)

Previous changes from v2.28.3

  • πŸ› Bug fixes


    • πŸ›  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)