我正在尝试使用 SimpleXML 反序列化 Android 设备上的对象。在一个 Maven 文件中,我使用了排除项的依赖项(我在另一个问题中遵循了建议,因为不排除这些依赖项,我无法启动应用程序):
<dependency>
<groupId>org.simpleframework</groupId>
<artifactId>simple-xml</artifactId>
<version>2.6.7</version>
<exclusions>
<!-- StAX is not available on Android -->
<exclusion>
<artifactId>stax</artifactId>
<groupId>stax</groupId>
</exclusion>
<exclusion>
<artifactId>stax-api</artifactId>
<groupId>stax</groupId>
</exclusion>
<!-- Provided by Android -->
<exclusion>
<artifactId>xpp3</artifactId>
<groupId>xpp3</groupId>
</exclusion>
</exclusions>
为了测试,我只写了一个简单的类:
class Test {
String s;
}
我试图得到一个对象:
Test t = null;
try {
t = serializer.read(Test.class, source);
} catch (Exception e) {
e.printStackTrace();
}
Log.v("t",t.s);
但在最后一行,当我尝试读取字段 ts 时,我收到了如下错误:
Could not find method javax.xml.stream.XMLInputFactory.newInstance, referenced from method org.simpleframework.xml.stream.StreamProvider.<init>
unable to resolve static method 3372: Ljavax/xml/stream/XMLInputFactory;.newInstance ()Ljavax/xml/stream/XMLInputFactory;
dead code 0x0006-0009 in Lorg/simpleframework/xml/stream/StreamProvider;.<init>
unable to find class referenced in signature (Ljavax/xml/stream/XMLEventReader;)
问题的原因可能是什么,我该如何解决?