google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

Upgrading past Hilt Alpha Versions breaks Searchview behaviour #3021

Closed 1298se closed 3 years ago

1298se commented 3 years ago

https://user-images.githubusercontent.com/40322963/141402261-853e2ce5-699b-4915-947e-0c91a087b5b2.mp4

For one of my projects I moved from Hilt 2.28-alpha to 2.3.5. Now, my keyboard flickers when I return from the detail page to the list. The keyboard previous stayed open. The pull request is here https://github.com/1298se/Trackuriboh/commit/d34db789b34defd3e2f7280a47d658897b70a111

As a sanity check I went back and reapplied only the Hilt migration changes. I also incremented every release of Hilt and it seems like it works fine on all alpha releases - once it gets to beta and beyond this behaviour occurs. Any ways to resolve this issue?

danysantiago commented 3 years ago

This is not quite related to Hilt. But very likely it is because the newer versions of Hilt, post-alpha bring in a newer version of androidx Fragments or Activity that is causing this behaviour change. The default behaviour in Gradle is to use the highest version if there are transitive deps conflicts. You can confirm this by just updating AppCompat or the Navigation library in your project but not Hilt.

You can try updating Hilt and forcing to keep an older version of androidx but we can't guarantee things will work. You can also force an upgrade of a transitive dep if you find that the Hilt version that works for you is depending on an androidx Fragment or Activity with a bug.

If you need to know which versions of the androidx libs Hilt brings you can always take a look at the POM file: in https://search.maven.org/artifact/com.google.dagger/hilt-android/2.40.1/aar

<dependency>
  <groupId>androidx.activity</groupId>
  <artifactId>activity</artifactId>
  <version>1.3.1</version>
</dependency>
<dependency>
  <groupId>androidx.fragment</groupId>
  <artifactId>fragment</artifactId>
  <version>1.3.6</version>
</dependency>