简体   繁体   English

Android Firebase数据库异常:未定义无参数构造函数

[英]Android Firebase Database exception: not define a no-argument constructor

I'm receiving an error presented below: 我收到以下错误:

com.google.firebase.database.DatabaseException: Class com.example.admin.albumsviewer.Album$Info does not define a no-argument constructor. com.google.firebase.database.DatabaseException:com.example.admin.albumsvi​​ewer.Album $ Info类未定义无参数构造函数。 If you are using ProGuard, make sure these constructors are not stripped. 如果您使用的是ProGuard,请确保未删除这些构造函数。

In fact in my model class I have declared no-argument constructors: 实际上,在我的模型类中,我已经声明了无参数的构造函数:

package com.example.admin.albumsviewer;

import java.util.ArrayList;
import java.util.List;

public class Album {
    String nazwa;
    String wykonawca;
    String okladkaAlbumu;
    String logoZespolu;
    Info info;
    Utwory utwory;

    public String getNazwa() {
        return nazwa;
    }

    public void setNazwa(String nazwa) {
        this.nazwa = nazwa;
    }

    public String getWykonawca() {
        return wykonawca;
    }

    public void setWykonawca(String wykonawca) {
        this.wykonawca = wykonawca;
    }

    public String getOkladkaAlbumu() {
        return okladkaAlbumu;
    }

    public void setOkladkaAlbumu(String okladkaAlbumu) {
        this.okladkaAlbumu = okladkaAlbumu;
    }

    public String getLogoZespolu() {
        return logoZespolu;
    }

    public void setLogoZespolu(String logoZespolu) {
        this.logoZespolu = logoZespolu;
    }

    public Info getInfo() {
        return info;
    }

    public void setInfo(Info info) {
        this.info = info;
    }

    public Utwory getUtwory() {
        return utwory;
    }

    public void setUtwory(Utwory utwory) {
        this.utwory = utwory;
    }

    public Album(){

    }

    public Album(String nazwa, String wykonawca, String okladkaAlbumu, String logoZespolu, Info info, Utwory utwory) {
        this.nazwa = nazwa;
        this.wykonawca = wykonawca;
        this.okladkaAlbumu = okladkaAlbumu;
        this.logoZespolu = logoZespolu;
        this.info = info;
        this.utwory = utwory;
    }

    public class Info {
        String gatunek;
        int cena;
        int rokWydania;

        public String getGatunek() {
            return gatunek;
        }

        public void setGatunek(String gatunek) {
            this.gatunek = gatunek;
        }

        public int getCena() {
            return cena;
        }

        public void setCena(int cena) {
            this.cena = cena;
        }

        public int getRokWydania() {
            return rokWydania;
        }

        public void setRokWydania(int rokWydania) {
            this.rokWydania = rokWydania;
        }

        public Info() {
        }

        public Info(String gatunek, int cena, int rokWydania) {
            this.gatunek = gatunek;
            this.cena = cena;
            this.rokWydania = rokWydania;
        }
    }

    public class Utwory {
        List<String> utwory;

        public List<String> getUtwory() {
            return utwory;
        }

        public void setUtwory(List<String> utwory) {
            this.utwory = utwory;
        }

        public Utwory(){
        }

        public Utwory(List<String> utwory) {
            this.utwory = utwory;
        }
    }
}

I'am quite confused how to fix that issue. 我很困惑如何解决该问题。 Thanks in advance. 提前致谢。

Info and Utwory shouldn't be inner classes nested inside Album . InfoUtwory不应该是嵌套在Album内部类。 Make them independent classes instead. 使它们成为独立的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase数据库:尽管存在错误,但仍出现“无参数构造函数”错误 - Firebase Database: Getting “No-Argument Constructor” Error Despite Having It Exception或其子类中的无参数构造函数 - No-argument constructor in Exception or its subclasses 无参构造函数调用2参数构造函数 - No-argument constructor calling 2-argument constructor Java无参数构造函数:抛出不可能的异常,或者有空的catch块? - Java no-argument constructor: Throw impossible exception, or have empty catch block? 隐式调用超类中的无参数构造函数 - Calling no-argument constructor in superclass implicitly 强制超类包含无参数构造函数 - Force superclasses to include a no-argument constructor kafka 流异常找不到 org.apache.kafka.common.serialization.Serdes$WrapperSerde 的公共无参数构造函数 - kafka streams exception Could not find a public no-argument constructor for org.apache.kafka.common.serialization.Serdes$WrapperSerde 在编译时强制存在无参数构造函数(Java) - Enforce presence of no-argument constructor at compile time (Java) 为无参数构造函数的类创建动态代理 - Create a dynamic proxy for a class without no-argument constructor Scala类的最终def this()声明没有公共的无参数构造函数 - Scala class final def this() declares no public no-argument constructor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM