繁体   English   中英

找不到Android Studio DatatypeFactoryImpl

[英]Android Studio DatatypeFactoryImpl not found

我尝试使用android studio生成XML文件,但出现此错误:

 Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found.

问题来自“ JAXBContext”行。 我有一个功能,使XML文件的代码是

        try {

        File file = new File("D:\\Github\\Comedu\\file.xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(Resultat.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        // output pretty printed
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        jaxbMarshaller.marshal(this, file);
        jaxbMarshaller.marshal(this, System.out);

    } catch (JAXBException e) {
        e.printStackTrace();
    }

在android studio上,我将xerces包添加到我的buildpath中,所以我不知道如何解决这个问题。

如果您是Android开发人员,则如文档所述Note that you must supply your own implementation (such as Xerces); Android does not ship with a default implementation. Note that you must supply your own implementation (such as Xerces); Android does not ship with a default implementation. https://developer.android.com/reference/javax/xml/datatype/DatatypeFactory.html#newInstance%28%29

因此,尝试添加依赖项xercesImpl

Maven的:

<!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.12.0</version>
</dependency>

摇篮:

// https://mvnrepository.com/artifact/xerces/xercesImpl
compile group: 'xerces', name: 'xercesImpl', version: '2.12.0'

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM