Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hilt: Compiler processor doesn't recognize options dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation #2040

Closed
jt-9 opened this issue Aug 12, 2020 · 17 comments · Fixed by #2453

Comments

@jt-9
Copy link

jt-9 commented Aug 12, 2020

Hello.

I am developing multi-module Android project with Hilt version 2.28.3-alpha. I have included dagger compiler to every module which requests or provides. After compilation in Android studio 4.0.1 I see warnings in every module:

warning: The following options were not recognized 
by any processor: '[dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation, kapt.kotlin.generated]'

Though these are warnings I was taught to pay attention to them as well, since they might indicate a potential problem with logic or performance, or anything else.

Applications seems to compile and run successfully, but are these warnings important? May be I am missing some Dagger Hilt setting?

Thank you.

@bcorso
Copy link

bcorso commented Aug 13, 2020

Hi @jt-9, I wasn't able to reproduce this. Do you have a minimal reproducible example app that you could share that demonstrates the behavior?

@lukas1
Copy link

lukas1 commented Aug 22, 2020

Could it be that a module that reports this doesn't use some of the Hilt features? Maybe the module that reports this doesn't use any @AndroidEntryPoint ? Just guessing, I haven't checked that assumption at all.

@jt-9
Copy link
Author

jt-9 commented Aug 25, 2020

Hi @bcorso, sorry for late response. Here is reproducible example app https://github.com/jt-9/HiltMultiModuleMRP, if you build it with command ./gradlew clean assembleRelease
output should be similar to

...
> Task :component_db:kaptDebugKotlin
warning: The following options were not recognized by any processor: '[dagger.hilt.android.internal.disableAndroidSuperclassValidation, kapt.kotlin.generated]'
...

As for other warning with '[dagger.fastInit, kapt.kotlin.generated]' still working on that.

@lukas1 Thanks for sharing an idea, will try it.

@jt-9
Copy link
Author

jt-9 commented Aug 25, 2020

@bcorso I updated the repository with app that reproduces warnings https://github.com/jt-9/HiltMultiModuleMRP

Thanks to @lukas1 point I added module base_ui which contains BaseViewModelActivity but doesn't use any Dagger Hilt feature, but it still includes compiler as a part of common include config.gradle which results in warning

The following options were not recognized by any processor: '[kapt.kotlin.generated, dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation]'

@bcorso
Copy link

bcorso commented Sep 1, 2020

Thanks for the repro @jt-9!

Unfortunately, I don't think there's much we can do on our end about it. This appears to be a kapt issue (note: it doesn't happen with annotationProcessor).

It seems kapt ignores Processor#getSupportedOptions() if none of the Processor#getSupportedAnnotationsTypes() are found in the sources.

In your case, component_db uses Dagger but not Hilt annotations in the sources, which is why the Dagger option dagger.fastInit doesn't show up as unrecognized in that case. However, for base_ui you don't use Dagger or Hilt annotations in the sources, which is why all of the options show up as unrecognized.

Solution

There's a couple options here:

  1. File a bug against kapt to not ignore compiler options
  2. Remove the Dagger/Hilt processors from modules that don't use Dagger/Hilt annotations
  3. Ignore the warnings

@Chang-Eric
Copy link
Member

I'm going to close this since there doesn't seem to be much we can do about this warning from our side.

@jt-9
Copy link
Author

jt-9 commented Nov 9, 2020

Thank you, I think I will file a bug to Kotlin team

@ansman
Copy link

ansman commented Feb 10, 2021

@jt-9 Did you ever end up filing an issue on the Kotlin issue tracker?

ansman added a commit to ansman/dagger that referenced this issue Feb 11, 2021
… points

When Hilt Android is run on a module that contains no entry points, KAPT
will log an error about disableAndroidSuperclassValidation not being a
support option. This is because the Hilt Gradle plugin will add this
option when applied but if no entry points exists, no processor actually
accepts that option.

With this fix, all hilt processors accept these options (though they are
unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt
plugin is applied, but Hilt isn't used but for those cases the user can
simply skip applying the plugin.

This fixes google#2040
ansman added a commit to ansman/dagger that referenced this issue Feb 11, 2021
… points

When Hilt Android is run on a module that contains no entry points, KAPT
will log an error about disableAndroidSuperclassValidation not being a
support option. This is because the Hilt Gradle plugin will add this
option when applied but if no entry points exists, no processor actually
accepts that option.

With this fix, all hilt processors accept these options (though they are
unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt
plugin is applied, but Hilt isn't used but for those cases the user can
simply skip applying the plugin.

This fixes google#2040
ansman added a commit to ansman/dagger that referenced this issue Feb 11, 2021
… points

When Hilt Android is run on a module that contains no entry points, KAPT
will log an error about disableAndroidSuperclassValidation not being a
support option. This is because the Hilt Gradle plugin will add this
option when applied but if no entry points exists, no processor actually
accepts that option.

With this fix, all hilt processors accept these options (though they are
unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt
plugin is applied, but Hilt isn't used but for those cases the user can
simply skip applying the plugin.

This fixes google#2040
@ansman
Copy link

ansman commented Feb 11, 2021

This issue can partially be solved by dagger. I opened a PR to fix it: #2372

copybara-service bot pushed a commit that referenced this issue Mar 4, 2021
… points.

When Hilt Android is run on a module that contains no entry points, KAPT will log an error about `disableAndroidSuperclassValidation` not being a support option. This is because the Hilt Gradle plugin will add this option when applied but if no entry points exists, no processor actually accepts that option.

With this fix, all Hilt processors accept these options (though they are unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt plugin is applied, but Hilt isn't used but for those cases the user can simply skip applying the plugin.

Fixes #2040
Closes #2372

RELNOTES="Reduce the possibility of KAPT logging warnings due to no processor supporting `disableAndroidSuperclassValidation` when no Android entry points are in the source module."
PiperOrigin-RevId: 360770265
copybara-service bot pushed a commit that referenced this issue Mar 4, 2021
… points.

When Hilt Android is run on a module that contains no entry points, KAPT will log an error about `disableAndroidSuperclassValidation` not being a support option. This is because the Hilt Gradle plugin will add this option when applied but if no entry points exists, no processor actually accepts that option.

With this fix, all Hilt processors accept these options (though they are unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt plugin is applied, but Hilt isn't used but for those cases the user can simply skip applying the plugin.

Fixes #2040
Closes #2372

RELNOTES="Reduce the possibility of KAPT logging warnings due to no processor supporting `disableAndroidSuperclassValidation` when no Android entry points are in the source module."
PiperOrigin-RevId: 360770265
copybara-service bot pushed a commit that referenced this issue Mar 4, 2021
… points.

When Hilt Android is run on a module that contains no entry points, KAPT will log an error about `disableAndroidSuperclassValidation` not being a support option. This is because the Hilt Gradle plugin will add this option when applied but if no entry points exists, no processor actually accepts that option.

With this fix, all Hilt processors accept these options (though they are unused). This will prevent KAPT from logging these warnings in most cases.

It is still possible for warnings to be logged, for example if the Hilt plugin is applied, but Hilt isn't used but for those cases the user can simply skip applying the plugin.

Fixes #2040
Closes #2372

RELNOTES="Reduce the possibility of KAPT logging warnings due to no processor supporting `disableAndroidSuperclassValidation` when no Android entry points are in the source module."
PiperOrigin-RevId: 360836064
@ghost
Copy link

ghost commented Jul 21, 2022

I had same problem.
added: id 'com.google.dagger.hilt.android' to build gradle and it works

@invweb
Copy link

invweb commented Dec 24, 2022

@JerryApplegarth and what does that mean? where did you add that?

@invweb
Copy link

invweb commented Dec 24, 2022

ok, I added to 'plugins', getting exception: The compiler option dagger.hilt.android.internal.projectType is not a recognized Hilt option. Is there a typo?

@mobielbekeken-thijs
Copy link

For me adding this to the build file (in the android block) fixed it:

hilt {
    enableAggregatingTask = true
}

reference: https://youtrack.jetbrains.com/issue/KT-46940/Kapt-reports-a-warning-The-following-options-were-not-recognized-by-any-processor...#focus=Comments-27-5211169.0-0

@GeorgePeterPandian
Copy link

Hi Team, I tried possible fixes suggested nothing works. Is there any other ticket open related to this ?

@Chang-Eric
Copy link
Member

@GeorgePeterPandian do you have more information on what you're hitting? The main issue should have been solved by c70cf2d. The actual error you're hitting plus your Dagger/Hilt version would be helpful.

Also, note that the fix we put in helps with cases where you only use part of the Hilt APIs, but if you have a module where you have the Hilt processors and use none of the Hilt annotations, then I think this problem still exists and you would need to remove the Hilt processors from that module.

@jamesonwilliams
Copy link

jamesonwilliams commented Dec 31, 2023

As reported on StackOverflow, you can get rid of these warnings if you:

Move the id "kotlin-kapt" to the bottom of plugins{} in build.gradle Module-level.

But if you're using KSP (and so don't have any kapt plugin), that workaround won't help. Just tested with 2.50.

@ALEX5402
Copy link

ALEX5402 commented May 5, 2024

Thank you, I think I will file a bug to Kotlin team

Can you tell me please how you fixed that warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
10 participants