【发布时间】:2015-12-29 14:45:58
【问题描述】:
无法在 Android 上运行 XML 解析器 Jackson
import android.content.Context;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
in onCreate(){
ObjectMapper xmlMapper = new XmlMapper();
Channel root = xmlMapper.readValue(stringXML, Channel.class);
}
@JacksonXmlRootElement(localName = "channel")
public static class Channel {
public List<Item> channel;
}
public static class Item {
@JacksonXmlProperty(localName = "item")
public String item;
}
错误是:
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory;
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList
【问题讨论】:
-
如果你问“如何解决这个错误?”,什么是“如何在 Android Studio 中重命名项目的主名称?”问题在开头帖子?而且您的代码不完整,无法编译。请创建一个minimal reproducible example。
-
@Roman,抱歉,没有删除之前的问题