Eclipse 不会为 Butter Knife 生成 .apt_generated 文件夹 [英] Eclipse doesn't generate the .apt_generated folder for Butter Knife
问题描述
我已仔细按照
首先你需要确保你有一个 Android 项目和 不是 Android 库 项目,因为 Butterknife 使用 处理库项目一种不同的方法.
要执行此操作,请单击 Project Properties
并转到 Android
部分.有关更多详细信息,请参阅Android 文档:
然后在 project/.factorypath 中检查这些设置:
<factorypathentry kind="WKSPJAR" id="/PotlatchClient/libs/butterknife-5.1.2.jar" enabled="true" runInBatchMode="false"/></工厂路径>
project/.settings/org.eclipse.jdt.apt.core.prefs:
eclipse.preferences.version=1org.eclipse.jdt.apt.aptEnabled=trueorg.eclipse.jdt.apt.genSrcDir=.apt_generatedorg.eclipse.jdt.apt.reconcileEnabled=true
project/.settings/org.eclipse.jdt.core.prefs:
eclipse.preferences.version=1org.eclipse.jdt.core.compiler.processAnnotations=启用
最后在 Eclipse 中刷新并清理以进行完全重建.
另一个建议的问题是将 JDK 更改为 1.7,这意味着您只能针对 Kitkat (4.4) 或更高版本.
I have carefully followed the instructions in the official guide to enable annotations in my Eclipse ADT 3.8.
That is, Annotation Processing and Factory Path are properly configured:
My Android application compiles successfully. It runs too, of course, but I get obvious NPEs due to views that are expected to be initialized by Butter Knife stay null
.
If I change the configuration to generate, say .apt_generated_foo_bar
, Eclipse will create that folder. But empty.
Any ideas on how I can convince Eclipse to create the appropriate classes in .apt_generated
?
This question (and answer) duplicates this one: Butterknife does not create anything in .apt_generated directory
First you need to make sure you have an Android project and not an Android library project because Butterknife handles library projects using a different approach.
To do this click Project Properties
and go to the Android
section. For further details see the Android documentation:
Then check these settings in project/.factorypath:
<factorypath>
<factorypathentry kind="WKSPJAR" id="/PotlatchClient/libs/butterknife-5.1.2.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
project/.settings/org.eclipse.jdt.apt.core.prefs:
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=.apt_generated
org.eclipse.jdt.apt.reconcileEnabled=true
project/.settings/org.eclipse.jdt.core.prefs:
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.processAnnotations=enabled
Finally do a refresh in Eclipse and clean to do a full rebuild.
The problem with the other suggestion is changing the JDK to 1.7 means you can only target Kitkat (4.4) or higher.
这篇关于Eclipse 不会为 Butter Knife 生成 .apt_generated 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!