user3034944
user3034944

Reputation: 1741

Enable Annotation processing for existing projects Android studio 3.3

I am using Android studio 3.3 and trying to use Dagger2 in my project. However, the annotation processing does not work in it and the annotation classes are not generated.

I am add the library as follows to my gradle file.

implementation 'com.google.dagger:dagger:2.21'
annotationProcessor 'com.google.dagger:dagger-compiler:2.21'

I have also specified the annotationProcessorOptions

 javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }

What have I tried:

  1. Closing the project.

  2. Going to Configure -> Settings -> Build, Execution and Deployment ->Compiler ->Annotation Processors and checked "Enable annotation processing"

  3. Removing my project from the recent projects list

  4. Re-importing the project from the disk.

  5. Invalidate cache/restart

However, even after doing the above steps the annotations are not being generated for my current app. I have also tried this and this, but the steps in the second link do not seem to appear for my current project settings and the compiler option is greyed out. Is there a way I can enable them for my current app?

Upvotes: 1

Views: 2329

Answers (2)

elektroarge
elektroarge

Reputation: 23

the real solution is: 1 - create a compiler.xml in .idea/ folder and write that code in it.

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="CompilerConfiguration">
    <annotationProcessing>
      <profile default="true" name="Default" enabled="true" />
    </annotationProcessing>
  </component>
</project>

2- invalidate and restart

Upvotes: 1

user3034944
user3034944

Reputation: 1741

I resolved the issue myself. I had to do the whole process mentioned in the question all over again, restart the machine and clean rebuild the project. It worked fine after that. Hope this is helpful for anyone looking for a solution to a similar issue

Upvotes: 0

Related Questions