Dagger2 v2.27 Release Notes

Release Date: 2020-03-13 // 19 days ago
  • 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)
    3. Fix #1665: Add an explicit check for member injection of Kotlin object classes rather than crashing. (550d696)
    4. 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.

Previous changes from v2.26

  • What's new

    🚚 1. Fix #1700: Remove usages of non-Android Guava APIs. (0925e8f)

    1. Fix #1720: Fix incremental dagger-android-processor in kapt when using dagger.android.experimentalUseStringKeys. (6a0ce58)
    2. 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.@Moduleabstract 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