我使用类和基元类型创建了类File。
当我尝试换行时,出现错误:
无法找到生成的Parcelable类,请验证您的类是否已正确配置,以及Parceler是否生成了Parcelable类。
File.class:
@Parcel
public class File {
int id;
FileData data;
FileMeta meta;
String cypher_key;
boolean isNew;
public File() {
isNew = true;
}
public File(int id, FileData data, FileMeta meta, String cypher_key) {
this.id = id;
this.data = data;
this.meta = meta;
this.cypher_key = cypher_key;
isNew = false;
}
public int getId() {
return this.id;
}
public int getFileDataId() {
return this.data.getId();
}
public int getFileDataVersion() {
return this.data.getVersion();
}
public String getFileUrl() {
return this.data.getUrl();
}
public String getFileType() {
return this.data.getTagType();
}
public String getFileDaraInit() {
return this.data.getInintDate();
}
public String getMetaDetailes() {
return this.meta.getDetails();
}
public int getMetaVersion() {
return this.meta.getVersion();
}
public String getMetaDateInit() {
return this.meta.getInitDate();
}
public String getMetaDateModif() {
return this.meta.getModifDate();
}
public boolean isNew(){
return this.isNew;
}
public void setFileType(String type){
if (data!=null){
data.setTypeTag(type);
}else{
data = new FileData();
data.setTypeTag(type);
}
}
}
FileMeta.class:
@Parcel
public class FileMeta {
String details;
int version;
String dt_initialization;
String dt_modification;
public FileMeta() {
}
public FileMeta(String details, int version, String dt_initialization, String dt_modification) {
this.details = details;
this.version = version;
this.dt_initialization = dt_initialization;
this.dt_modification = dt_modification;
}
public String getDetails() {
return this.details;
}
public int getVersion() {
return this.version;
}
public String getInitDate() {
return this.dt_initialization;
}
public String getModifDate() {
return this.dt_modification;
}
}
FileData.class:
@Parcel
public class FileData {
int id;
String url;
int version;
String type_tag;
String dt_initialization;
public FileData() {
}
public FileData(int id, String url, int version, String type_tag, String dt_initialization) {
this.id = id;
this.url = url;
this.version = version;
this.type_tag = type_tag;
this.dt_initialization = dt_initialization;
}
public int getId() {
return this.id;
}
public int getVersion() {
return this.version;
}
public String getUrl() {
return this.url;
}
public String getTagType() {
return this.type_tag;
}
public String getInintDate(){
return this.dt_initialization;
}
public void setTypeTag(String typeTag){
this.type_tag = typeTag;
}
}
我的代码有什么问题?
非常感谢您的帮助。
答案 0 :(得分:2)
如果没有生成Parcelable
类,则抛出此错误。这很可能是由于构建配置错误造成的。验证您的构建并确保您按如下方式声明Parceler依赖项:
compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"