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

Support for Kotlin 1.5.20 #2684

Closed
Jeff11 opened this issue Jun 11, 2021 · 9 comments
Closed

Support for Kotlin 1.5.20 #2684

Jeff11 opened this issue Jun 11, 2021 · 9 comments

Comments

@Jeff11
Copy link

Jeff11 commented Jun 11, 2021

With Kotlin 1.5.20-RC I get this error.

Works with Kotlin 1.5.10.

Dagger version 2.37

/Users/username/projects/myproject/appname/build/tmp/kapt3/stubs/devAppnameDebug/de/company/appname/ApplicationMain.java:47: error: [Hilt]
public final class ApplicationMain extends company.appname.ApplicationBase {
             ^
  Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
  See https://dagger.dev/hilt/gradle-setup.html
  [Hilt] Processing did not complete. See error above for details.
/Users/username/projects/myproject/appname/build/tmp/kapt3/stubs/devAppnameDebug/de/company/appname/ui/SecondFragment.java:43: error: [Hilt]
public final class SecondFragment extends company.appname.ui.base.BaseFragment {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
  See https://dagger.dev/hilt/gradle-setup.html
  [Hilt] Processing did not complete. See error above for details.
@bcorso
Copy link

bcorso commented Jun 11, 2021

Did you forget to apply the Gradle Plugin (dagger.hilt.android.plugin)?

@Jeff11
Copy link
Author

Jeff11 commented Jun 11, 2021

I am using the Gradle plugin. Until Kotlin 1.5.10 there are no problems with the build. It just started with 1.5.20-M1 and -RC.

I can switch to 1.5.10 and the build will work.

@burhankhanzada
Copy link

i also have this issue and @Jeff11 is rith its working fine with 1.5.10

@SteinerOk
Copy link

Also with 1.5.20-RC not working compiler argument for disabling InstallIn check:

        javaCompileOptions {
            annotationProcessorOptions {
                arguments += [
                        "dagger.hilt.disableModulesHaveInstallInCheck": "true"
                ]
            }
        }

@bcorso
Copy link

bcorso commented Jun 13, 2021

This sounds like a bug in the kotlin/kapt plugin rather than Hilt. In particular, javaCompilerOptions.annotationProcessorOptions are just getting ignored in general, as mentioned in #2684 (comment). This ends up causing Hilt to fail because the Hilt Gradle plugin sets these options in HiltGradlePlugin.kt.

FWIW, it looks like the processing options set through kapt.javacOptions do still work, so as a workaround you can set the options manually:

kapt {
    javacOptions {
        // These options are normally set automatically via the Hilt Gradle plugin, but we
        // set them manually to workaround a bug in the Kotlin 1.5.20
        option("-Adagger.fastInit=ENABLED")
        option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
    }
}

@slavonnet
Copy link

kapt.use.worker.api=false
fixes many strange issues from kapt

@bcorso
Copy link

bcorso commented Jun 23, 2021

I've filed a bug with kotlin here: https://youtrack.jetbrains.com/issue/KT-47416

FunkyMuse pushed a commit to FunkyMuse/Vigilante that referenced this issue Jun 25, 2021
@SerggioC
Copy link

kapt.use.worker.api=false
fixes many strange issues from kapt

It'll decrease build speed though:
https://kotlinlang.org/docs/kapt.html#improving-the-speed-of-builds-that-use-kapt

To improve the speed of builds that use kapt, you can enable the Gradle worker API for kapt tasks. Using the worker API lets Gradle run independent annotation processing tasks from a single project in parallel, which in some cases significantly decreases the execution time.

@bcorso sulution works. 👍

shubham08gupta pushed a commit to shubham08gupta/MatchingGame that referenced this issue Jun 26, 2021
nvmnghia added a commit to nvmnghia/yacv that referenced this issue Jun 30, 2021
There's a bug in kotlin, tracked here:

https://youtrack.jetbrains.com/issue/KT-47416

This workaround is applied in this commit:

google/dagger#2684 (comment)
@mmathieum
Copy link

Kotlin 1.5.21 fixes the issue for me
https://github.com/JetBrains/kotlin/releases/tag/v1.5.21

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

No branches or pull requests

7 participants