修改
清理并重建后,不会生成类
我在尝试使用Parcels.wrap()
Unable to find generated Parcelable class for xyz.xyz.models.reclamation.Reclamation, verify that your class is configured properly and that the Parcelable class xyz.xyz.models.reclamation.Reclamation$$Parcelable is generated by Parceler.
但是创建了Reclamation$$Parcelable
类,我可以看到它的内容。
这就是我的傻瓜:
compile 'org.parceler:parceler-api:1.1.6'
annotationProcessor 'org.parceler:parceler:1.1.6'
尝试将annotationProcessor
更改为apt
会导致构建错误。
多数人回收课程
@Parcel
public class Reclamation {
public Reclamation() {
}
private int reclamationProductID;
private Integer preference;
private String takingDate1;
private String takingDate2;
private int takingAddressID;
private String takingAddressStreet;
private String takingAddressCity;
private String takingAddressZipCode;
private int type;
private String takingAddressCompany;
// + getters setters
}
它崩溃的地方
ServiceStepFour_.builder().arg(Constants.ARG_RECLAMATION, Parcels.wrap(reclamation)).build();
我将它与Android Annotations结合使用。
有人知道为什么会这样吗?
答案 0 :(得分:4)
虽然文档说你必须将这些行放到gradle中:
compile 'org.parceler:parceler-api:1.1.6'
annotationProcessor 'org.parceler:parceler:1.1.6'
将其更改为:
compile 'org.parceler:parceler-api:1.1.6'
apt 'org.parceler:parceler:1.1.6'
确保您要使用的所有文件都使用@Parcel
进行注释。
我有A类和B类变量,我忘了注释B类。这就是为什么从annotationProcessor
改为apt
会给我一个构建错误。
答案 1 :(得分:1)
在我的情况下,当我从apt移动到annotationProcessor时,我必须删除这一行
apply plugin: 'com.neenbedankt.android-apt'