Hilt: Library modules cannot find symbol for provides functions when included in application
See original GitHub issueKotlin version: 1.3.72 Hilt (android, compiler, and plugin) version: 2.28-alpha
We have a separate library that we share across our android apps. I have been following the migration guide https://dagger.dev/hilt/migration-guide. I have removed all the prior Dagger code from our application, but dagger still exists in our library and we currently cannot change that. Thus we need to use Hilt and Dagger together.
I have used the flag -Adagger.hilt.disableModulesHaveInstallInCheck=true
since we have a lot of modules, thus I opted for an AgreggatedModule
with all my modules in it.
We have a module in our library called CommunicationModule
which includes two other modules like such:
@Module(includes = {RabbitModule.class, IdentityModule.class, HostnameModule.class})
. Inside our SharedFunctionsModule
inside of our app, the CommunicationModule
is included as such: @Module(includes = [CommunicationsModule::class])
. This SharedFunctionsModule
is added to the AgreggatedModule
.
When I run a clean build, I get the following error for each provides function inside the SharedFunctionsModule
that I can’t seem to decipher what the problem is (this is just one of about 10):
/Users/landon/Desktop/app/build/generated/source/kapt/debug/core/DaggerApplication_HiltComponents_ApplicationC.java:560: error: cannot find symbol
local = HostnameModule_ProvideHostProviderFactory.provideHostProvider(hostnameModule, SharedFunctionsModule_ProvideAppTypeFactory.provideAppType(sharedFunctionsModule));
^
symbol: method provideHostProvider(HostnameModule,AppType)
location: class HostnameModule_ProvideHostProviderFactory
The dagger equivalent of this app works perfectly fine and this issue has never cropped up, so its intriguing to see it, but its blocking a full migration to Hilt.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top GitHub Comments
Thanks for providing the extra details! Glad upgrading resolved things.
The issue is likely that the Hilt plugin enables fastInit by default, but fastInit wasn’t fully functional in version 2.14.1.
Either way, upgrading all of your libraries to the same version (if possible) is definitely the way to go in this case.
In the
SharedFunctions
library we have the compiler:We are not using
kapt
in this library since its a pure Java library.Our application module does not have the
com.google.dagger:dagger-compiler:<VERSION>
though since I removed it in the migration to Hilt.