安卓:包裹类包装错误 [英] Android: Parcel class wrapping error

查看:164
本文介绍了安卓:包裹类包装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的类文件,为类和基本类型。

I created class File with to classes and primitive types.

当我尝试把它包起来,有一个错误:

When i try to wrap it, have an error:

无法找到产生Parcelable类,检验类配置正确,并且该Parcelable类是由Parceler产生的。

Unable to find generated Parcelable class, verify that your class is configured properly and that the Parcelable class is generated by Parceler.

File.class:

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:

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:

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

什么错在我的code?

What wrong in my code?

大感谢您的帮助。

推荐答案

这是如果没有生成 Parcelable 类抛出的错误。这很可能是由于错误配置构建。验证您的构建,并确保您在Parceler依赖性声明如下:

This is the error thrown if no Parcelable classes are generated. This is most likely due to a build misconfiguration. Verify your build and make sure you have the Parceler dependencies declared as follows:

compile "org.parceler:parceler-api:1.0.4"
apt "org.parceler:parceler:1.0.4"

http://parceler.org/#getting_parceler

这篇关于安卓:包裹类包装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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