In my case the problem was incompatibility between Android Gradle Plugin and Hilt library. After upgrading Hilt to the latest version, I can also use the latest AGP.
[EDIT]
It seems that recent release of Android Gradle Plugin has fixed the issue and
AGP version 7.0.0-beta05
works with Hilt version 2.37
.
Link to related Github issue