question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hilt: Library modules cannot find symbol for provides functions when included in application

See original GitHub issue

Kotlin 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:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
bcorsocommented, Jul 31, 2020

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.

1reaction
LandonPatmorecommented, Jul 29, 2020

In the SharedFunctions library we have the compiler:

    (daggerVersion = 2.14.1)

    // Dagger Android
    implementation "com.google.dagger:dagger:$project.daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$project.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-compiler:$project.daggerVersion"
    annotationProcessor "com.google.dagger:dagger-android-processor:$project.daggerVersion"

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot find symbol import dagger.hilt.android.components ...
I'm trying to include dagger hilt to my multimodule project with just three modules (app, frameworks_and_drivers, interface_adapters).
Read more >
Dependency injection with Hilt | Android Developers
... with Hilt · Hilt in multi-module apps · Use Hilt with other Jetpack libraries ... Get a user-resettable advertising ID · Calendar...
Read more >
databinding errror: Error: symbol not found - Issue Tracker
The first time after build sucessfully. app module's DataBinderMapperImpl @Override // androidx.databinding.DataBinderMapper public List<DataBinderMapper> ...
Read more >
Dagger Hilt Testing Error - error: cannot find symbol ...
My issue was due to having multiple dependencies of the different versions and different dependency notations and I was missing the support lib....
Read more >
Android : error: cannot find symbol @dagger.hilt.InstallIn(value ...
Android : error: cannot find symbol @dagger. hilt.InstallIn(value = {ApplicationComponent.class}) [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found