Wrong error in @Binds attempt
See original GitHub issueHello,
I have had a problem that took a while to solve and didn’t know what was the cause of it,
I have a modular Android project and i keep my repository interfaces in a module called database
, for example:
interface RecipientRepository
The implementation of this interface is found in two modules called dev
and mock
.
The mock class looks like this:
@Singleton
class RecipientRepositoryMock @Inject constructor() : RecipientRepository
My android application is using flavors so i have flavors for mock and dev, so i use this in gradle:
mockImplementation project(":mock")
devImplementation project(":dev")
//hardcoded data
testImplementation project(":mock")
Our server had some problems so i had to switch to mock data on dev flavor, wrote this in my dagger module:
@Binds
abstract fun bindRecipientRepository(repository: RecipientRepositoryMock): RecipientRepository
Looks like Android Studio lets me autocomplete RecipientRepositoryMock and brings no error.
All seems fine but when i try to run i get this error:
FlavorDataModule.java:76: error: @Binds methods' parameter type must be assignable to the return type
public abstract repository.RecipientRepository bindRecipientRepository(@org.jetbrains.annotations.NotNull()
I think binds should first check if the class specified as paramter exists before checking if it extends the return type, I got no clue that the class could not be found because i forgot to add my mock dependency to the application.
This is an error with Android Studio, but it may improve debugging for others.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6
Top GitHub Comments
I’m going to close this since its been a while without a response. Feel free to still add a repro and I’ll open it back up.
Hi Rachieru,
Thanks for reporting!
I’ll take a look and see if there’s anything we can do about it.