enable Annotation Processors option in Android Studio 2.2
Solution 1
Close the project. In the "Welcome to Android Studio" dialog click "Configure" in the bottom right corner.
Then,
Settings > Build, Execution, Deployment > Compiler > Annotation Processors. Tick 'Enable annotation processing'.
If that does not work. Delete the project from "Welcome to Android Studio" dialog and open from new.
Worked for me.
Solution 2
Solution 3
You can enable Annotation Processors without closing your project in Android Studio 2.3:
File -> Other Settings -> Default Settings
Build, Execution, Deployment -> Compiler -> Annotation Processors ->
Enable annotation processing.
Don't forget to clean, build, invalidate and restart after that.
Cheers!
Solution 4
https://stackoverflow.com/a/38698186/4024146
and after do: File > Invalidate Caches / Restart... > Invalidate and Restart
Solution 5
Open compiler.xml in the .idea folder. I had the following:
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
I simply changed enable to true and re-opened project.
Related videos on Youtube
jonathanrz
I work as developer for over 10 years. I started working as a C++ developer, then I moved to a startup and developed android apps and their backend in Rails. After that I worked as a consultant at Thoughtworks. Now I work as an android developer at HE:labs.
Updated on February 01, 2021Comments
-
jonathanrz over 3 years
I'm trying to use java 8 in my project and for that I added the jack compiler.
After enabling jack I started having problems with libraries that use Annotation Processing and looking in the web I read that I need android studio 2.2 and com.android.tools.build:gradle:2.2.0-alpha6 to compile libraries that generate code from annotations.
I download Android Studio 2.2 preview 6 and converted my project to it. And after that I discovered that the apt gradle plugin is not supported anymore and then I needed to change every dependency that use apt to the use the new annotationProcessor option.
Ex:
apt "org.projectlombok:lombok:$rootProject.lombokVersion"
to
annotationProcessor "org.projectlombok:lombok:$rootProject.lombokVersion"
Now if I use "make project" the project is compiled without problems, but if I try to execute it I have errors with the code that should be generated by the annotations.
Also when I open the project I receive a warning from the lombok plugin "Annotation processing seems to be disabled for the project". When I open the project settings and go to "Build -> Compiler" I can't find Annotation Processors.
So, my question is: How can I enable Annotation Processors in Android Studio 2.2? This feature was disabled? If yes, how can I generate the code from annotations?
--EDIT-- I'm making a PullRequest to change the project to compile with Java8, you can check the PR here: https://github.com/jonathanrz/myexpenses-android/pull/57
-
oldergod over 7 yearsJacques Koorts's answer is great. The key is to close the current project because
Annotation Processors
are not displayed in Gradle projects. You need to access the Compiler menu from the root.
-
-
jonathanrz almost 8 yearsThanks for you reply :). It solved the lombok warning but aren't executing the annotation processing. I updated my question with a link to the repository if you want to do any tests.
-
Jacques Koorts almost 8 yearsI cloned your project and picked up a few things: 1. Don't commit IDE auto generated files eg. .idea so check your gitignore. 2. App runs fine on my Android Studio 2.1.2
-
jonathanrz almost 8 yearsthanks for the info about the idea files. About the project, the master branch are running without problem. This PR has the code to enable java8: github.com/jonathanrz/myexpenses-android/pull/57. Ps: the PR has code from another PR, I will merge the another PR soon, so the diff will be more simple.
-
Jacques Koorts almost 8 yearsCan you disable the jack compiler and take it from there? Doing that shows me new errors like getting latest gradle (you don't have the latest gradle plugin or wrapper configured)
-
jonathanrz almost 8 yearsIf I disable jack I can't compile with java 8. But I will try to solve those problems and get back to jack.
-
Johann almost 8 years"Annotation Processors" does not exist in Android Studio 2.1.2
-
Jacques Koorts almost 8 yearsI'm using stable 2.1.3 and I have it. If you still don't see it see my answer at Aug 1 at 11:52
-
lilienberg almost 8 yearsI also searched for the annotation processor option in the settings and could not find it. My mistake always was to click on the "Compiler" option which is not a folder. Just above there is another "Compiler" option with subelements also containing the annotation processors.
-
Apoorv Khatreja over 7 yearsI took a screenshot of the pane in Android Studio 2.2.1. There doesn't seem to be a section for annotation processors. What am I missing?
-
P.Bra over 7 years@appoorv-Khatreja You can not find it, because you are on a current project as well said by Jacques Koorts. So close your current project. Then open the Configure/Settings menu in Android Studio (on bottom right). Then choose Build,Execution,Deployment/Compiler then Annocation Processors and then you can check "Enable annotation processing".
-
KWA over 7 yearsYou also can find it with project opened at "File" > "Other Settings" > "Default Settings..."
-
IgorGanapolsky over 7 yearsThere is no such thing as Compiler > Annotation Processors in Android Studio 2.3.
-
davebshow about 7 yearsThis right here solved my problem. Doing the silly "remove from start screen" hack didn't work!
-
Jürgen 'Kashban' Wahlmann almost 7 yearsNot working for me. I try to run org.AndroidAnnotations which was fine with APT but I cannot get it to work with Android Annotation Processor. The Processor simply does not kick in.
-
Tudor almost 7 yearsin your gradle file you must change apt with annotationProcessor. For example apt "org.androidannotations:androidannotations:$AAVersion" -> annotationProcessor "org.androidannotations:androidannotations:$AAVersion"..... stackoverflow.com/questions/42622060/…
-
Krease about 6 yearsLook at the other answers below - you don't need to close your project. Also note that there are two "Compiler" labels in the settings dialog - one can be expanded (this is where the setting is), the other cannot
-
Chad Schultz over 4 yearsThis isn't working for me. At first I thought it was, but the red lines came back. The errors go away when Android Studio is starting up, or immediately after running tests, but then they quickly return. Even after copying over a compiler.xml file with the correct setting set, I still experience the error. No solution so far.
-
Tudor over 4 years@ChadSchultz are you using Java or Kotlin? for Kotlin you must add kapt(kotlin annotation processor) to gradle as a dependency
-
Asad over 4 yearsuseful answer (y) specially for kotlin