Dagger: Hilt build fails if set annotationProcessorOptions in gradle

Created on 11 Jun 2020  Â·  3Comments  Â·  Source: google/dagger

I use Room and dagger hilt in my project.
If I set annotationProcessorOptions for exporting schema of room, the build fails.

    android {
        ...
        defaultConfig {
            ...
            javaCompileOptions {
                annotationProcessorOptions {
                    arguments = ["room.schemaLocation":
                                 "$projectDir/schemas".toString()]
                }
            }
        }
    }
> Task :app:kaptDebugKotlin FAILED
/Users/hiroyukitamura/StudioProjects/dagger-hilt-example/app/build/tmp/kapt3/stubs/debug/com/github/aakira/hilt/ui/second/SecondActivity.java:7: エラー: [Hilt]
public final class SecondActivity extends androidx.appcompat.app.AppCompatActivity {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
  [Hilt] Processing did not complete. See error above for details./Users/hiroyukitamura/StudioProjects/dagger-hilt-example/app/build/tmp/kapt3/stubs/debug/com/github/aakira/hilt/ui/main/MainActivity.java:7: エラー: [Hilt]
public final class MainActivity extends androidx.appcompat.app.AppCompatActivity {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
  [Hilt] Processing did not complete. See error above for details./Users/hiroyukitamura/StudioProjects/dagger-hilt-example/app/build/tmp/kapt3/stubs/debug/com/github/aakira/hilt/ui/main/MainSecondFragment.java:7: エラー: [Hilt]
public final class MainSecondFragment extends androidx.fragment.app.Fragment {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
  [Hilt] Processing did not complete. See error above for details./Users/hiroyukitamura/StudioProjects/dagger-hilt-example/app/build/tmp/kapt3/stubs/debug/com/github/aakira/hilt/ui/main/MainFirstFragment.java:7: エラー: [Hilt]
public final class MainFirstFragment extends androidx.fragment.app.Fragment {
             ^
  Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin?
  [Hilt] Processing did not complete. See error above for details./Users/hiroyukitamura/StudioProjects/dagger-hilt-example/app/build/tmp/kapt3/stubs/debug/com/github/aakira/hilt/App.java:7: エラー: [Hilt]
public final class App extends android.app.Application {
             ^
  Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin?
  [Hilt] Processing did not complete. See error above for details.
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
   > java.lang.reflect.InvocationTargetException (no error message)

Is there any workaround?

Most helpful comment

Use += to append to the annotation processor options. Currently the use of = overwrites anything else which is set.

All 3 comments

Use += to append to the annotation processor options. Currently the use of = overwrites anything else which is set.

thanks so much and I'm sorry for lack of basic knowledge

It's a common occurrence!

https://github.com/google/dagger/pull/1884/files#diff-49a5cbf76a7c2a5b0b84afd4b3cb861eR103-R106

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SAGARSURI picture SAGARSURI  Â·  3Comments

peter-tackage picture peter-tackage  Â·  3Comments

zeshaoaaa picture zeshaoaaa  Â·  4Comments

feinstein picture feinstein  Â·  3Comments

pedrovarela86 picture pedrovarela86  Â·  3Comments