本文介绍了在Android Studio 2.2中启用“注释处理器”选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中使用java 8,为此我添加了jack编译器。

I'm trying to use java 8 in my project and for that I added the jack compiler.

启用插孔后我开始遇到使用Annotation的库的问题处理和查看网络我读到我需要android studio 2.2和com.android.tools.build:gradle:2.2.0-alpha6来编译从注释生成代码的库。

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.

我下载Android Studio 2.2预览版6并将我的项目转换为它。之后我发现不再支持apt gradle插件,然后我需要将使用apt的每个依赖项更改为使用新的annotationProcessor选项。

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"

annotationProcessor "org.projectlombok:lombok:$rootProject.lombokVersion"

现在,如果我使用make project,项目编译没有问题,但如果我尝试执行它我的代码应该由注释生成错误。

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.

当我打开项目时,我收到来自lombok插件注释的警告处理似乎对项目禁用。当我打开项目设置并转到构建 - >编译器时,我找不到注释处理器。

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.

所以,我的问题是:如何启用注释处理器在Android Studio 2.2中?此功能已被禁用?如果是,我如何从注释中生成代码?

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--
我正在使用PullRequest将项目更改为使用Java8进行编译,你可以在这里查看PR:

--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

推荐答案

关闭项目。在欢迎使用Android Studio对话框中,点击右下角的配置。

Close the project. In the "Welcome to Android Studio" dialog click "Configure" in the bottom right corner.

然后,

如果不起作用。从欢迎使用Android Studio对话框中删除项目,然后从新打开。

If that does not work. Delete the project from "Welcome to Android Studio" dialog and open from new.

为我工作。

这篇关于在Android Studio 2.2中启用“注释处理器”选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 17:03