在 Android Studio 2.2 中启用 Annotation Processors 选项 [英] enable Annotation Processors option in Android Studio 2.2

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

问题描述

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

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

启用 jack 后,我开始遇到使用注释处理的库的问题,并在网上查看我读到我需要 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.

例如:

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 插件的警告该项目似乎禁用了注释处理".当我打开项目设置并转到Build -> Compiler"时,我找不到 Annotation Processors.

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?

--编辑--我正在创建一个 PullRequest 来更改项目以使用 Java8 进行编译,您可以在此处查看 PR:https://github.com/jonathanrz/myexpenses-android/pull/57

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

那么,

设置 > 构建、执行、部署 > 编译器 > 注释处理器.勾选启用注释处理".

Settings > Build, Execution, Deployment > Compiler > Annotation Processors. Tick 'Enable annotation processing'.

如果这不起作用.从欢迎使用 Android Studio"对话框中删除项目并从新打开.

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

为我工作.

这篇关于在 Android Studio 2.2 中启用 Annotation Processors 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆