0

Is that possible? I have changed a few basic things in my code and want to make a clean build to see how many things needs to be adjusted now. This results in 1000s of cannot find symbol class ... messages in my Messages Gradle Build window.

So I want to run the annotation processor manually now to get rid of those messages and only see the relevant messages (looking through so many messages is cumbersome and I know that all annotated classes can be build by the annotation processor without problems).

Is that somehow possible? How do I run the annotation processor in android studio manually?

prom85
  • 16,896
  • 17
  • 122
  • 242

2 Answers2

0

You should never have to run Annotation processors manually (unless of course you are developing one).

Make sure you have Annotation Processors enabled in Android Studio (https://www.jetbrains.com/help/idea/2017.1/configuring-annotation-processing.html), Build > Clean project, and then Build > Rebuild project.

If you have everything set up correctly, this should work. However if your build is failing due to an annotation processor (Example: Dagger not meeting dependencies graph) then you will need to figure out the underlying issue.

Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
  • it fails because of compilation errors.... When making a build android studio will never run the annotation processor if there is a compile error somewhere in my code. That's why I want to run the processor without compiling... I simply WANT to run the processor only – prom85 May 04 '17 at 07:43
  • That's incorrect. All annotation processors are executed before compilation of any other code. Therefore, if you have a compilation error in a class referenced by the annotation processor, you need to fix that, and you wont solve it by manually running the annotation processor. As a matter of fact, it should return the same errors than if it was run by the build. – Robert Estivill May 04 '17 at 07:49
  • I'm using annotation processors for my database, moving all this code to a module and compiling this module works. After doing so I see about 100 errors in my main app. If I would have been able to run the annotation processor manually, I would have been able to see those 100 errors without all the missing class errors and without moving my database code to a module just for the sake of compiling the module and so force the annotation processor to run on those classes... – prom85 May 04 '17 at 08:16
  • Did you ever figure out how to run an annotation processor manually? – user346443 Sep 18 '18 at 04:41
0

If you are working with kotlin and using kapt there should be a task named kaptDebugKotlin you can access using gradle CLI by simply executing this command in the terminal ./gradlew app:kaptDebugKotlin Make sure you replace app with your module name in case you have a multi-module project.

If you are working with java then simply replace app:kaptDebugKotlin with compileDebugJavaWithJavac and that should execute your annotation processor.

to force the build to continue in case of compilation error add --continue to the command in the terminal.

Happy coding.

AouledIssa
  • 2,528
  • 2
  • 22
  • 39