猿问

SimpleXML:ConstructorException

我正在尝试解析一些像这样的RSS 2.0提要:https : //audioboom.com/channels/4682117.rss


我的模特看起来像这样


Rss类(Java文件,Kotlin也给我带来了麻烦)


@Root(name = "rss", strict = false)

@Namespace(prefix = "itunes", reference = "http://www.itunes.com/dtds/podcast-1.0.dtd")

public class RSSFeed {


    @Element(name = "title", required = false)

    @Path("channel")

    public String channelTitle = null;


    @Element(name = "description", required = false)

    @Path("channel")

    public String description = null;


    @Element(name = "url", required = false)

    @Path("channel/image")

    String imageUrl = null;


    @ElementList(name = "item", inline = true, required = false)

    @Path("channel")

    public List<Article> articleList = null;

}

物品类别(科特林文件)


@Root(name = "item", strict = false)

@Namespace(prefix = "itunes", reference = "http://www.itunes.com/dtds/podcast-1.0.dtd")

class Article{


    @set:Path("title")

    @get:Path("title")

    @set:Text(required = false)

    @get:Text(required = false)

    var title: String? = null


    @set:Element(name = "link", required = false)

    @get:Element(name = "link", required = false)

    var url: String? = null


    @set:Element(name = "enclosure", required = false)

    @get:Element(name = "enclosure", required = false)

    var enclosure: Enclosure? = null


    @set:Element(name = "guid", required = false, data = true)

    @get:Element(name = "guid", required = false, data = true)

    var id: String? = null


    @set:Namespace(reference = "http://www.itunes.com/dtds/podcast-1.0.dtd")

    @get:Namespace(reference = "http://www.itunes.com/dtds/podcast-1.0.dtd")

    @set:Element(name = "image", required = false)

    @get:Element(name = "image", required = false)

    var image: Image? = null


从我启用Progaurd。我开始出现此错误:


java.lang.RuntimeException:org.simpleframework.xml.core.ConstructorException:默认构造函数不能接受方法上的只读@ org.simpleframework.xml.Element(data = false,name = duration,required = false,type = void) com.myapp.model.rss.Article类中的“持续时间”


慕标5832272
浏览 237回答 1
1回答
随时随地看视频慕课网APP

相关分类

Java
我要回答